CleanCut / green

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

Green 2.0 fails on Windows #74

Closed MinchinWeb closed 9 years ago

MinchinWeb commented 9 years ago

It seems that Green 2.0 isn't working on Windows.

When I run green tests -vv, with Python 2.7.10, the output I get is:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
    assert main_name not in sys.modules, main_name
AssertionError: __main__
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
    assert main_name not in sys.modules, main_name
AssertionError: __main__
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
    assert main_name not in sys.modules, main_name
AssertionError: __main__
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
    assert main_name not in sys.modules, main_name
AssertionError: __main__
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
    assert main_name not in sys.modules, main_name
AssertionError: __main__
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
    assert main_name not in sys.modules, main_name
AssertionError: __main__
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
    assert main_name not in sys.modules, main_name
AssertionError: __main__
Traceback (most recent call last):
  File "C:\Python27\Lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "S:\Documents\GitHub\colourettu\env27\Scripts\green.exe\__main__.py", line 9, in <module>
  File "S:\Documents\GitHub\colourettu\env27\lib\site-packages\green\cmdline.py", line 79, in main
    result = run(test_suite, stream, args) # pragma: no cover
  File "S:\Documents\GitHub\colourettu\env27\lib\site-packages\green\runner.py", line 91, in run
    manager = multiprocessing.Manager()
  File "C:\Python27\Lib\multiprocessing\__init__.py", line 99, in Manager
    m.start()
  File "C:\Python27\Lib\multiprocessing\managers.py", line 528, in start
    self._address = reader.recv()
EOFError

When I run green tests -vv, with Python 3.4.3, the output I get is:

Traceback (most recent call last):
  File "S:\Documents\GitHub\colourettu\env34\lib\site-packages\green\process.py", line 48, in __call__
    result = self.__callable(*args, **kwargs)
  File "S:\Documents\GitHub\colourettu\env34\lib\site-packages\green\process.py", line 294, in poolRunner
    t.class_name  = target.split('.')[-2]
IndexError: list index out of range

Traceback (most recent call last):
  File "S:\Documents\GitHub\colourettu\env34\lib\site-packages\green\process.py", line 48, in __call__
    result = self.__callable(*args, **kwargs)
  File "S:\Documents\GitHub\colourettu\env34\lib\site-packages\green\process.py", line 294, in poolRunner
    t.class_name  = target.split('.')[-2]
IndexError: list index out of range

Traceback (most recent call last):
  File "S:\Documents\GitHub\colourettu\env34\lib\site-packages\green\process.py", line 48, in __call__
    result = self.__callable(*args, **kwargs)
  File "S:\Documents\GitHub\colourettu\env34\lib\site-packages\green\process.py", line 294, in poolRunner
    t.class_name  = target.split('.')[-2]
IndexError: list index out of range

and then it hangs, and I get sick of waiting, so I press CTRL+C, and I get:

Traceback (most recent call last):
  File "C:\Python34\Lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python34\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "S:\Documents\GitHub\colourettu\env34\Scripts\green.exe\__main__.py", line 9, in <module>
  File "S:\Documents\GitHub\colourettu\env34\lib\site-packages\green\cmdline.py", line 79, in main
    result = run(test_suite, stream, args) # pragma: no cover
  File "S:\Documents\GitHub\colourettu\env34\lib\site-packages\green\runner.py", line 107, in run
    msg = queue.get()
  File "<string>", line 2, in get
  File "C:\Python34\Lib\multiprocessing\managers.py", line 732, in _callmethod
    kind, result = conn.recv()
  File "C:\Python34\Lib\multiprocessing\connection.py", line 250, in recv
    buf = self._recv_bytes()
  File "C:\Python34\Lib\multiprocessing\connection.py", line 306, in _recv_bytes
    [ov.event], False, INFINITE)
InterruptedError: [Errno 4] Interrupted function call

I think this might be a Windows issue, because the tests pass fine on Travis-CI (see https://travis-ci.org/MinchinWeb/colourettu/builds/72882262 )

Again the tests are from colourettu.

CleanCut commented 9 years ago

Sorry about the slow response. I have been swamped.

Your problem is that you need an __init__.py file in your tests directory.

In 2.0.1 green now properly handles the failure and reports it, along with some advice as to how to fix it.

MinchinWeb commented 9 years ago

Thanks for the help! I got it working now.

CleanCut commented 9 years ago

Great! Glad to hear it.

It turns out this is a very common setup for python packages (a tests directory without an __init__.py), so I've created #75 -- I plan to have version be able to run without adding the __init__.py