CleanCut / green

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

How to run coverage when invoking green via the setup.py runner? #174

Closed jean closed 6 years ago

jean commented 6 years ago

I asked this here too: https://stackoverflow.com/q/47567902/274318

I configured an alias for green as a setup.py command.

At first it looks like test dependencies are being installed (Processing coverage-4.4.2-py3.5.egg) and then all of a sudden they aren't (The 'coverage' module is not installed). What's going wrong?

(DictORM) 14:15 john@john:~/git/DictORM(master)$ python setup.py test --run-coverage
running green
Searching for coveralls
Best match: coveralls 1.2.0
Processing coveralls-1.2.0-py3.5.egg

Using /home/john/repos/git/DictORM/.eggs/coveralls-1.2.0-py3.5.egg
Searching for coverage
Best match: coverage 4.4.2
Processing coverage-4.4.2-py3.5.egg

Using /home/john/repos/git/DictORM/.eggs/coverage-4.4.2-py3.5.egg
Searching for docopt>=0.6.1
Best match: docopt 0.6.2
Processing docopt-0.6.2-py3.5.egg

Using /home/john/repos/git/DictORM/.eggs/docopt-0.6.2-py3.5.egg
Fatal: The 'coverage' module is not installed.  Have you run 'pip install coverage' ???
CleanCut commented 6 years ago

I am so sorry for the slow response! I just started a new job, and have been spending all my time getting up-to-speed there.

After digging into this, the problem appears to be that for the module to be importable under this scenario it has to be listed in the .eggs/green*.egg/EGG-INFO/requires.txt file that gets generated by setup.py during the running of this command.

Coverage is an "optional dependency", which is a concept that Python packages don't actually have. So I just left coverage out of the dependency listing in both requirements.txt and setup.py and green simply tries to import it at runtime and enables the functionality if it is present.

Unfortunately, that breaks in this situation. :-(

Since this will break for anyone else under this same scenario, I suppose that it is time to simply pull coverage in as an official dependency and remove the "optional" verbage in the documentation.

CleanCut commented 6 years ago

Oh, and @rolobio, I blame this entirely on you! 😛 Always making me work... 😉

rolobio commented 6 years ago

Sorry, next time I’ll use a less awesome test runner!

Maybe you could do an extras_require in your setup.py?

CleanCut commented 6 years ago

Lol! I knew I should have waited for your response first. So there IS such a thing as officially optional.

Oh well. I already did the work of cutting out the optional support, and I like it because it's less lines and simpler. So coverage is just required now. New release coming soon...

CleanCut commented 6 years ago

Fixed in 2.12.0, which was just released.