CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
785 stars 75 forks source link

Modified lines 321 and 322 to fix Issue # 176 #222

Closed bkmd11 closed 4 years ago

bkmd11 commented 4 years ago

In recreating the problem I have found that if there is an import error the 'ModuleImportFailure' gets triggered, and exception_method returns a string that splits at the first space, and if a windows path has a space this causes the bug.

The discover option will go through more directories than unittest, which can possibly try to run tests that weren't expected/wanted, and lead to not knowing where the import error could be caused.

EX:

my project\ _my_project.py
_tests\
_test_this.py
_side_project\
_fancy_side_project_with_import_error.py
_tests\
_test_side_project.py

when green is run in "my project" the error message will be: AttributeError: 'ModuleImportFailure' object has no attribute 'my'

My solution is to split on the "(" in the suite string and to strip remaining white-space on the end. This will give the full file path where the error is and shouldn't change any other functionality.

I did have to change one test to make it pass because their was no "(" to split on, but in my manual testing of the error the "suite" object always has the parenthesis, so I felt this was needed. I don't know if this will affect anything on different operating systems

CleanCut commented 4 years ago

Included in 3.1.3, just released.