Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect retrieval of mutation cached status #280

Open
Meg4Bit opened this issue May 23, 2023 · 3 comments
Open

Incorrect retrieval of mutation cached status #280

Meg4Bit opened this issue May 23, 2023 · 3 comments

Comments

@Meg4Bit
Copy link

Meg4Bit commented May 23, 2023

mutmut/mutmut/cache.py

Lines 441 to 442 in 53d4aa1

line_obj_by_line[mutation_id.line] = Line.get(sourcefile=sourcefile, line=mutation_id.line, line_number=mutation_id.line_number)
line = line_obj_by_line[mutation_id.line]

When there are duplicate lines in the file, the program uses cache of the first of such lines. Instead should be used line_number

@boxed
Copy link
Owner

boxed commented May 23, 2023

Well no, it can't use the line number, because mutmut is built to handle when line number changes due to edits to the file.

Could you show an example of having the same code in multiple lines? That seems pretty strange to me.

@Meg4Bit
Copy link
Author

Meg4Bit commented May 23, 2023

But updates of line numbers occur on the early stages, meaning that the lines are up to date during read of cache.

Here are the examples, I've faced while testing Flask:
https://github.com/pallets/flask/blob/d0bf462866289ad8bfe29b6e4e1e0f531003ab34/src/flask/blueprints.py#L531
https://github.com/pallets/flask/blob/d0bf462866289ad8bfe29b6e4e1e0f531003ab34/src/flask/blueprints.py#L550

Guess that there can be other situations when lines are similar.

@boxed
Copy link
Owner

boxed commented May 23, 2023

Ah. That's a good point. I'm open to a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants