summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiro Motoki <motoki@da.jp.nec.com>2014-09-29 07:36:19 +0900
committerSachi King <nakato@nakato.io>2016-01-07 12:20:15 +1100
commit6e472b4905411a39e993c81c382a27ca9c771ef5 (patch)
treeaf068da6ecab784fd50ec925dc8554665dccab46
parent474019d35be10117dbded09d7f72c26b57400c7c (diff)
downloadpbr-stable/kilo.tar.gz
Make setup.py --help-commands work without testrepositorykilo-eol0.11.1stable/kilo
testr command is registered by pbr.hooks.commands if testrepository is installed, so there is no need to setup the entry point in setup.cfg. (cherry-picked from 946cf80b750f3735a5d3b0c2173f4eaa7fad4a81) Change-Id: I95aae12d1ac810b6d1d09b71f2a0d87be5ccb6ab Closes-Bug: #1375048
-rw-r--r--pbr/packaging.py24
-rw-r--r--pbr/testr_command.py27
2 files changed, 33 insertions, 18 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index 9ed1dbb..fe460f9 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')
@@ -246,27 +247,20 @@ class _PipInstallTestRequires(object):
self.install_test_requirements()
_copy_test_requires_to(self.egg_info)
-try:
- from pbr import testr_command
-
- class TestrTest(testr_command.Testr, _PipInstallTestRequires):
- """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
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