mutmut run leads to hardcoded error in 2.4.2
split_paths returns None on https://github.com/boxed/mutmut/blob/master/mutmut/main.py#L278
Iterating over None leads to an exception on https://github.com/boxed/mutmut/blob/master/mutmut/main.py#L293
Traceback (most recent call last):
File "/home/USER/.local/share/virtualenv/bin/mutmut", line 8, in <module>
sys.exit(climain())
File "/home/USER/.local/share/virtualenv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/USER/.local/share/virtualenv/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/USER/.local/share/virtualenv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/USER/.local/share/virtualenv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/USER/.local/share/virtualenv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/USER/.local/share/virtualenv/lib/python3.9/site-packages/mutmut/__init__.py", line 882, in wrapper
f(*args, **kwargs)
File "/home/USER/.local/share/virtualenv/lib/python3.9/site-packages/mutmut/__main__.py", line 140, in run
sys.exit(do_run(argument, paths_to_mutate, disable_mutation_types, enable_mutation_types, runner,
File "/home/USER/.local/share/virtualenv/lib/python3.9/site-packages/mutmut/__main__.py", line 286, in do_run
for p in split_paths(tests_dir):
TypeError: 'NoneType' object is not iterable
Replacing None with [] on line 278 fixes this problem for me, but I'm not familiar enough with the code to understand what's really going on.
Well there really shouldn't be any case where mutmut doesn't know where the tests are. That would break the logic that makes mutmut smart about what to rerun and not.
That being said, the hard crash like this isn't good. It would be better if it printed an error message saying it can't find the tests and ask you to add the required config in setup.cfg
Does mutmut attempt to detect test directories? I see https://github.com/boxed/mutmut/blob/master/mutmut/main.py#L119 which only seems to find tests in the current directory. Would it not be preferable to use the standard unittest test discovery, if possible?
Fwiw, using unittest.TestLoader().discover(path) or something similar might be preferable to find test dirs. I could look into getting the directories from that.
That might work for unittest, but it's not a general solution. mutmut doesn't know about what test framework you're using.
Automatic discovery for some users still sounds like an improvement to me? Not sure if I should look into it any further though as it's not general, which doesn't seem possible anyway.
Yea.. I'm fine with doing that also.
Looks like the regression happened in 2.4.1 - a Dependabot PR which only updates mutmut 2.4.0 to 2.4.1 broke my project. Not sure what the workaround is.