summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pbr/packaging.py26
-rw-r--r--pbr/testr_command.py27
-rw-r--r--test-requirements.txt2
3 files changed, 34 insertions, 21 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index ebf1a8d..3bc625d 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -39,6 +39,7 @@ from pbr import extra_files
from pbr import git
from pbr import options
import pbr.pbr_json
+from pbr import testr_command
from pbr import version
REQUIREMENTS_FILES = ('requirements.txt', 'tools/pip-requires')
@@ -170,27 +171,19 @@ class LocalInstall(install.install):
return du_install.install.run(self)
-try:
- from pbr import testr_command
-
- class TestrTest(testr_command.Testr):
- """Make setup.py test do the right thing."""
-
- command_name = 'test'
-
- def run(self):
- self.pre_run()
- # Can't use super - base class old-style class
- testr_command.Testr.run(self)
+class TestrTest(testr_command.Testr):
+ """Make setup.py test do the right thing."""
- _have_testr = True
+ command_name = 'test'
-except ImportError:
- _have_testr = False
+ def run(self):
+ # Can't use super - base class old-style class
+ testr_command.Testr.run(self)
def have_testr():
- return _have_testr
+ return testr_command.have_testr
+
try:
from nose import commands
@@ -201,7 +194,6 @@ try:
command_name = 'test'
def run(self):
- self.pre_run()
# Can't use super - base class old-style class
commands.nosetests.run(self)
diff --git a/pbr/testr_command.py b/pbr/testr_command.py
index 3440f02..141d715 100644
--- a/pbr/testr_command.py
+++ b/pbr/testr_command.py
@@ -44,12 +44,10 @@ import logging
import os
import sys
-from testrepository import commands
-
logger = logging.getLogger(__name__)
-class Testr(cmd.Command):
+class TestrReal(cmd.Command):
description = "Run unit tests using testr"
@@ -133,3 +131,26 @@ class Testr(cmd.Command):
logger.debug("_coverage_after called")
os.system("coverage combine")
os.system("coverage html -d ./cover %s" % self.omit)
+
+
+class TestrFake(cmd.Command):
+ description = "Run unit tests using testr"
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ print("Install testrepository to run 'testr' command properly.")
+
+
+try:
+ from testrepository import commands
+ have_testr = True
+ Testr = TestrReal
+except ImportError:
+ have_testr = False
+ Testr = TestrFake
diff --git a/test-requirements.txt b/test-requirements.txt
index 2b33504..6e4521c 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,7 +1,7 @@
coverage>=3.6
discover
fixtures>=0.3.14
-hacking>=0.9.2,<0.10
+hacking>=0.10.0,<0.11
mock>=1.0
python-subunit>=0.0.18
sphinx>=1.1.2,<1.2