CleanCut / green

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

ModuleImportFailure possibly caused by a path having a space character in it. #122

Closed dougthor42 closed 8 years ago

dougthor42 commented 8 years ago

Summary:

There appears to be an issue where AttributeError: 'ModuleImportFailure' object has no attribute <truncated path> is raised if a path as a space character in it.

Removing the space from path seems to fix the issue, but it might be something that should be looked into for future releases.

This issue is only see when ruing GitLab's Multi-Runner in a self-hosted environment - I can't reproduce it locally.

I believe that it has to do with the space in the path because the full path is:

C:\GitLab Multi-Runner\builds\5d1d0a61\0\dthor\emap-convert

while the error is only showing:

AttributeError: 'ModuleImportFailure' object has no attribute 'C:\GitLab'

Notes

This only occurs when I run green using GitLab's CI. The GitLab Multi Runner is on a Windows 8.1 x64 machine, running WinPython34 (x64). In addition, all of the unit testing runs inside a python virtual environment.

I'm still working on narrowing down exactly how to reproduce it, but that could take some time. In the mean time, let me know if there's any more info you'd like me to collect.

Exception Text

$ python -m green -ddd -vvv -s 1 -W -t --run-coverage emap-convert
2016-05-17 12:59:45     DEBUG Attempting to load target 'emap-convert' with file_pattern 'test*.py'
2016-05-17 12:59:45     DEBUG   Dotted module: C:\GitLab Multi-Runner\builds\5d1d0a61\0\dthor\emap-convert -> emap-convert.tests.test_convert
2016-05-17 12:59:45     DEBUG   Dotted module: C:\GitLab Multi-Runner\builds\5d1d0a61\0\dthor\emap-convert -> emap-convert.tests.test_utils
2016-05-17 12:59:45     DEBUG   Imported emap-convert.tests.test_utils
2016-05-17 12:59:45     DEBUG   Examining module emap-convert.tests.test_utils for test cases
2016-05-17 12:59:45     DEBUG     Examining test case TestRCtoXY
2016-05-17 12:59:45     DEBUG Test case names: ['test_rc_to_xy', 'test_sanity']
2016-05-17 12:59:45     DEBUG Load method: DISCOVER - emap-convert
2016-05-17 12:59:45     DEBUG Found 3 tests for target 'emap-convert'
Traceback (most recent call last):
  File "C:\WinPython34\python-3.4.4.amd64\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\WinPython34\python-3.4.4.amd64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\__main__.py", line 7, in <module>
    sys.exit(main())
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\cmdline.py", line 75, in main
    result = run(test_suite, stream, args, testing)
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\runner.py", line 92, in run
    targets = [(target, manager.Queue()) for target in toParallelTargets(suite, args.targets)]
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\loader.py", line 60, in toParallelTargets
    proto_test_list = toProtoTestList(suite)
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\loader.py", line 45, in toProtoTestList
    toProtoTestList(i, test_list, doing_completions)
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\loader.py", line 45, in toProtoTestList
    toProtoTestList(i, test_list, doing_completions)
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\loader.py", line 45, in toProtoTestList
    toProtoTestList(i, test_list, doing_completions)
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\loader.py", line 45, in toProtoTestList
    toProtoTestList(i, test_list, doing_completions)
  File "C:\temp\builds\python34_x64\48__full-refactor\lib\site-packages\green\loader.py", line 37, in toProtoTestList
    getattr(suite, exception_method)()
AttributeError: 'ModuleImportFailure' object has no attribute 'C:\GitLab'
Green 2.4.0, Coverage 4.0.3, Python 3.4.4
CleanCut commented 8 years ago

Looks like you have a pretty good grasp of the problem. Did you find a way to reproduce it outside of GitLab's environment?

dougthor42 commented 8 years ago

Sadly no, I was unable to reproduce it outside of GitLab.

I wouldn't worry too much about it. It seems that the workaround of not using spaces in the path works very well - I haven't had any issues since.

CleanCut commented 8 years ago

Okay, since you can't reproduce it independently AND have a workaround, I'm going to mark it as closed. If any of that changes, feel free to reopen the issue.