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

mutmut run leads to hardcoded error in 2.4.2 #258

Open
nkuttler opened this issue Sep 29, 2022 · 7 comments
Open

mutmut run leads to hardcoded error in 2.4.2 #258

nkuttler opened this issue Sep 29, 2022 · 7 comments

Comments

@nkuttler
Copy link

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.

@boxed
Copy link
Owner

boxed commented Sep 30, 2022

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

@nkuttler
Copy link
Author

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?

@nkuttler
Copy link
Author

nkuttler commented Oct 7, 2022

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.

@boxed
Copy link
Owner

boxed commented Oct 9, 2022

That might work for unittest, but it's not a general solution. mutmut doesn't know about what test framework you're using.

@nkuttler
Copy link
Author

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.

@boxed
Copy link
Owner

boxed commented Oct 14, 2022

Yea.. I'm fine with doing that also.

@l0b0
Copy link

l0b0 commented Oct 19, 2022

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.

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

3 participants