CleanCut / green

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

Properly handle the common case of tests/ without an __init__.py #75

Closed CleanCut closed 9 years ago

CleanCut commented 9 years ago

It is very common to have:

proj/
    module/
        __init__.py
        ...
    tests/
        (no __init__.py)
        ...

The main process discovers the tests fine, but when the worker receives the name of the module, it fails to load it when tests/ doesn't have an __init__.py.

Fixing this may also fix other run-green-from-a-different-directory-can't-load-tests problems.

ghost commented 9 years ago

Hey, thanks for addressing this.

It's also worth noting that if this were documented, I'd have just added the __init__.py and not thought twice about it, so that's possibly a perfectly suitable stopgap until a better solution is found.

Thanks again!

CleanCut commented 9 years ago

No problem! I have found that the biggest obstacle to fixing bugs is simply becoming aware that the bug even exists. Thanks for clueing me in!

CleanCut commented 9 years ago

@mekhami Okay, I'm baffled. I cannot reproduce the problem myself. Is there any way that you could provide me with a minimal project that has the problem? Everything I have tried has ended up actually being loaded and run successfully, whether or not there was an __init__.py present.

CleanCut commented 9 years ago

Okay, I can't reproduce the problem, so I'm going to close this issue. If someone can provide me with a way to actually reproduce the problem reliably, we'll reopen this issue and get it fixed.

MinchinWeb commented 9 years ago

@CleanCut, are you looking for a project that green won't run if there is a missing __init__.py?

CleanCut commented 9 years ago

@MinchinWeb Specifically, a project where tests/ is a sibling directory to the project code, and there is no tests/__init__.py and green won't run the tests.

MinchinWeb commented 9 years ago

@CleanCut, I think that was the issue with #74 : tests/ was a folder at the same level as the main module, and with no tests/__init__.py, green won't run the tests, but oddly only on Windows. See if colourettu will work as the test case you're looking for.