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)
Make setup.py --help-commands work without testrepositorykilo-eol0.11.1
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
Notes
Notes (review): Code-Review+2: lifeless <robertc@robertcollins.net> Code-Review+2: Monty Taylor <mordred@inaugust.com> Code-Review+2: Julien Danjou <julien@danjou.info> Code-Review+1: Akihiro Motoki <amotoki@gmail.com> Workflow+1: Julien Danjou <julien@danjou.info> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 08 Jan 2016 17:12:57 +0000 Reviewed-on: https://review.openstack.org/263928 Project: openstack-dev/pbr Branch: refs/heads/stable/kilo
-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
39from pbr import git 39from pbr import git
40from pbr import options 40from pbr import options
41import pbr.pbr_json 41import pbr.pbr_json
42from pbr import testr_command
42from pbr import version 43from pbr import version
43 44
44REQUIREMENTS_FILES = ('requirements.txt', 'tools/pip-requires') 45REQUIREMENTS_FILES = ('requirements.txt', 'tools/pip-requires')
@@ -246,27 +247,20 @@ class _PipInstallTestRequires(object):
246 self.install_test_requirements() 247 self.install_test_requirements()
247 _copy_test_requires_to(self.egg_info) 248 _copy_test_requires_to(self.egg_info)
248 249
249try:
250 from pbr import testr_command
251
252 class TestrTest(testr_command.Testr, _PipInstallTestRequires):
253 """Make setup.py test do the right thing."""
254 250
255 command_name = 'test' 251class TestrTest(testr_command.Testr):
256 252 """Make setup.py test do the right thing."""
257 def run(self):
258 self.pre_run()
259 # Can't use super - base class old-style class
260 testr_command.Testr.run(self)
261 253
262 _have_testr = True 254 command_name = 'test'
263 255
264except ImportError: 256 def run(self):
265 _have_testr = False 257 # Can't use super - base class old-style class
258 testr_command.Testr.run(self)
266 259
267 260
268def have_testr(): 261def have_testr():
269 return _have_testr 262 return testr_command.have_testr
263
270 264
271try: 265try:
272 from nose import commands 266 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
44import os 44import os
45import sys 45import sys
46 46
47from testrepository import commands
48
49logger = logging.getLogger(__name__) 47logger = logging.getLogger(__name__)
50 48
51 49
52class Testr(cmd.Command): 50class TestrReal(cmd.Command):
53 51
54 description = "Run unit tests using testr" 52 description = "Run unit tests using testr"
55 53
@@ -133,3 +131,26 @@ class Testr(cmd.Command):
133 logger.debug("_coverage_after called") 131 logger.debug("_coverage_after called")
134 os.system("coverage combine") 132 os.system("coverage combine")
135 os.system("coverage html -d ./cover %s" % self.omit) 133 os.system("coverage html -d ./cover %s" % self.omit)
134
135
136class TestrFake(cmd.Command):
137 description = "Run unit tests using testr"
138 user_options = []
139
140 def initialize_options(self):
141 pass
142
143 def finalize_options(self):
144 pass
145
146 def run(self):
147 print("Install testrepository to run 'testr' command properly.")
148
149
150try:
151 from testrepository import commands
152 have_testr = True
153 Testr = TestrReal
154except ImportError:
155 have_testr = False
156 Testr = TestrFake