summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-09-18 11:12:16 -0400
committerJason R. Coombs <jaraco@jaraco.com>2016-09-18 11:12:16 -0400
commit6dd23c73f2e7096711d477eb755439f3b93b5c3d (patch)
tree9f357eebf15cd89f2acbbda17da817ba6ad7a522
parent647f5d9a352919aedc99a6b69f22f85cb7f36455 (diff)
downloadpytest-runner-6dd23c73f2e7096711d477eb755439f3b93b5c3d.tar.gz
Reimplement run method to rely more on Setuptools' implementation when possible.
-rw-r--r--ptr.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/ptr.py b/ptr.py
index 94ef1d7..2e4ac3b 100644
--- a/ptr.py
+++ b/ptr.py
@@ -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.