Skip to content

Commit

Permalink
setup: workaround for pytest plugin loading bug
Browse files Browse the repository at this point in the history
For some reason the pytest_cache plugin is not being loaded properly
when using 'python setup.py test' to manage the test dependencies. If
all dependencies are installed in the site-packages directory this issue
doesn't occur. This issue seems to occur when test deps are missing and
therefore are fetched locally as eggs by 'python setup.py test'. The fix
is to manually call configure_setuptools_entrypoints() on pytest's
PluginManager object in order to properly register the plugin(s). An
alternate fix is to import pytest_cache and pass it to pytest's main
function's plugins kwarg.
  • Loading branch information
jtriley committed Feb 12, 2014
1 parent d7efdc7 commit dcef2b5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,20 @@ def finalize_options(self):
self.test_args.append('--live')

def run_tests(self):
#import here, cause outside the eggs aren't loaded
# import here, cause outside the eggs aren't loaded
import pytest
# Needed in order for pytest_cache to load properly
# Alternate fix: import pytest_cache and pass to pytest.main
import _pytest.config
pm = _pytest.config.get_plugin_manager()
pm.consider_setuptools_entrypoints()
errno = pytest.main(self.test_args)
sys.exit(errno)

console_scripts = ['starcluster = starcluster.cli:main']
extra = dict(test_suite="starcluster.tests",
tests_require=["pytest", "pytest-cov", "pytest-pep8",
"pytest-flakes"],
tests_require= ["pytest-cov", "pytest-pep8", "pytest-flakes",
"pytest"],
cmdclass={"test": PyTest},
install_requires=["paramiko>=1.12.1", "boto>=2.23.0",
"workerpool>=0.9.2", "Jinja2>=2.7",
Expand Down

0 comments on commit dcef2b5

Please sign in to comment.