From 6dd23c73f2e7096711d477eb755439f3b93b5c3d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 18 Sep 2016 11:12:16 -0400 Subject: Reimplement run method to rely more on Setuptools' implementation when possible. --- ptr.py | 23 +++++++++++++++++------ 1 file 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. -- cgit v1.2.1