diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-09-18 11:12:16 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-09-18 11:12:16 -0400 |
commit | 6dd23c73f2e7096711d477eb755439f3b93b5c3d (patch) | |
tree | 9f357eebf15cd89f2acbbda17da817ba6ad7a522 | |
parent | 647f5d9a352919aedc99a6b69f22f85cb7f36455 (diff) | |
download | pytest-runner-6dd23c73f2e7096711d477eb755439f3b93b5c3d.tar.gz |
Reimplement run method to rely more on Setuptools' implementation when possible.
-rw-r--r-- | ptr.py | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -128,12 +128,11 @@ class PyTest(orig.test): except AttributeError: return null() - def run(self): - """ - Override run to ensure requirements are available in this session (but - don't install them anywhere). - """ - self._build_egg_fetcher() + def _super_run(self): + if hasattr(orig.test, 'install_dists'): + return orig.test.run(self) + + # for backward compatibility with setuptools < 27.3 installed_dists = self.install_dists(self.distribution) if self.dry_run: self.announce('skipping tests (dry run)') @@ -141,6 +140,14 @@ class PyTest(orig.test): paths = map(_operator.attrgetter('location'), installed_dists) with self.paths_on_pythonpath(paths): self.with_project_on_sys_path(self.run_tests) + + def run(self): + """ + Override run to ensure requirements are available in this session (but + don't install them anywhere). + """ + self._build_egg_fetcher() + self._super_run() if self.result_code: raise SystemExit(self.result_code) return self.result_code @@ -180,6 +187,10 @@ class PyTest(orig.test): cmd.ensure_finalized() main_dist._egg_fetcher = cmd + @property + def _argv(self): + return ['pytest'] + self.addopts + def run_tests(self): """ Invoke pytest, replacing argv. |