Open udelledo opened 1 week ago
Could you create a project like this and put it up on github and send the link?
BTW, I get the same issue with https://github.com/nedbat/templite. With Python 3.10, install pytest and mutmut, then:
% python -V
Python 3.10.15
% pip install pytest mutmut
% pip install -e .
% mutmut run
generating mutants
done in 231ms
⠋ running stats
done
⠙ running clean tests
done
⠼ running forced fail test
done
Traceback (most recent call last):
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/bin/mutmut", line 8, in <module>
sys.exit(cli())
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/mutmut/__main__.py", line 1202, in run
mutants = sorted(mutants, key=lambda x: estimated_worst_case_time(x[1]))
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/mutmut/__main__.py", line 1202, in <lambda>
mutants = sorted(mutants, key=lambda x: estimated_worst_case_time(x[1]))
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/mutmut/__main__.py", line 1091, in estimated_worst_case_time
return sum(mutmut.duration_by_test[t] for t in tests)
File "/usr/local/virtualenvs/tmp-7bde11ae9ca1d4c/lib/python3.10/site-packages/mutmut/__main__.py", line 1091, in <genexpr>
return sum(mutmut.duration_by_test[t] for t in tests)
KeyError: 'tests/test_templite.py::TempliteTest::test_bad_nesting'
I made a new release.
There were a bunch of fixed on main
that made at least the templite
project run properly. Thanks Ned for a nice and clean reproduction scenario.
@udelledo please try 3.2.1 now
Thanks, and templite itself seems good:
% mutmut run
⠼ Generating mutants
done in 1ms
⠋ Listing all tests
Found 26 new tests, rerunning stats collection
⠙ Running stats
done
⠹ Running clean tests
done
⠴ Running forced fail test
done
Running mutation testing
⠋ 214/214 🎉 214 🫥 0 ⏰ 0 🤔 0 🙁 0 🔇 0
34.97 mutations/second
Awesome, version 3.2.1 didn't show the error anymore, but I'm still facing a problem. This time it is related to the interaction with another test library I have in my project.
In the plain test I have a test case where I use multiple verify statement because it's a parametrized test, but I'm not sure why this issue is being reported with mutmut.
I understand integration with other plugins/libraries might not be a primary concern of this library, nonetheless I would ask if there's any strategy you could think that would let me use the two libraries together.
maybe a mechanism that would let me extend the configuration for test execution with mutmut
I would think this is an issue with that library that you should discuss with them. Mutmut does not modify each test, so I would guess their check for multiple calls to verify()
per test is slightly broken, and doesn't actually check per test, but per process of the entire testing run or something. At the very least they should probably reset their check logic when pytest starts, as pytest will start multiple times in the same process in mutmut.
I'm running on python 3.9 with mutmut 3.2.0
Steps taken:
mutmut run
and had the following stacktraceNot sure if it's a matter of python version, or of test structures.