Merge lp:~lifeless/testtools/discovery into lp:~testtools-committers/testtools/trunk

Proposed by Robert Collins
Status: Merged
Approved by: Jonathan Lange
Approved revision: 72
Merged at revision: 72
Proposed branch: lp:~lifeless/testtools/discovery
Merge into: lp:~testtools-committers/testtools/trunk
Diff against target: 78 lines (+24/-18)
2 files modified
MANUAL (+13/-0)
testtools/run.py (+11/-18)
To merge this branch: bzr merge lp:~lifeless/testtools/discovery
Reviewer Review Type Date Requested Status
Jonathan Lange Approve
Review via email: mp+27459@code.launchpad.net

Commit message

Document and polish the test discovery feature.

Description of the change

Document and polish the test discovery feature.

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

Hey Rob,

Thanks for the polish & documentation. It's nice to see the manual kept up-to-date, and I'm sure it helps our users a lot.

Could you please capitalize Python in the MANUAL, and put a space between Python and its version number before you land this?

Thanks,
jml

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MANUAL'
2--- MANUAL 2010-06-11 00:51:36 +0000
3+++ MANUAL 2010-06-13 22:22:22 +0000
4@@ -213,3 +213,16 @@
5
6 Testtools provides a convenient way to run a test suite using the testtools
7 result object: python -m testtools.run testspec [testspec...].
8+
9+Test discovery
10+--------------
11+
12+Testtools includes a backported version of the Python2.7 glue for using the
13+discover test discovery module. If you either have python 2.7/3.1 or newer, or
14+install the 'discover' module, then you can invoke discovery::
15+
16+ python -m testtools.run discover [path]
17+
18+For more information see the Python2.7 unittest documentation, or::
19+
20+ python -m testtools.run --help
21
22=== modified file 'testtools/run.py'
23--- testtools/run.py 2010-06-11 00:04:30 +0000
24+++ testtools/run.py 2010-06-13 22:22:22 +0000
25@@ -54,6 +54,10 @@
26 # it won't be on old python versions.
27 # - print calls have been been made single-source python3 compatibile.
28 # - exception handling likewise.
29+# - The default help has been changed to USAGE_AS_MAIN and USAGE_FROM_MODULE
30+# removed.
31+# - A tweak has been added to detect 'python -m testtools.run' and use a
32+# better progName in that case.
33
34 FAILFAST = " -f, --failfast Stop on first failure\n"
35 CATCHBREAK = " -c, --catch Catch control-C and display results\n"
36@@ -88,28 +92,12 @@
37 level directory of the project.
38 """
39
40-USAGE_FROM_MODULE = """\
41-Usage: %(progName)s [options] [test] [...]
42-
43-Options:
44- -h, --help Show this message
45- -v, --verbose Verbose output
46- -q, --quiet Minimal output
47-%(failfast)s%(catchbreak)s%(buffer)s
48-Examples:
49- %(progName)s - run default set of tests
50- %(progName)s MyTestSuite - run suite 'MyTestSuite'
51- %(progName)s MyTestCase.testSomething - run MyTestCase.testSomething
52- %(progName)s MyTestCase - run all 'test*' test methods
53- in MyTestCase
54-"""
55-
56
57 class TestProgram(object):
58 """A command-line program that runs a set of tests; this is primarily
59 for making test modules conveniently executable.
60 """
61- USAGE = USAGE_FROM_MODULE
62+ USAGE = USAGE_AS_MAIN
63
64 # defaults for testing
65 failfast = catchbreak = buffer = progName = None
66@@ -135,7 +123,12 @@
67 self.defaultTest = defaultTest
68 self.testRunner = testRunner
69 self.testLoader = testLoader
70- self.progName = os.path.basename(argv[0])
71+ progName = argv[0]
72+ if progName.endswith('testtools%srun.py' % os.path.sep):
73+ progName = 'testtools.run'
74+ else:
75+ progName = os.path.basename(argv[0])
76+ self.progName = progName
77 self.parseArgs(argv)
78 self.runTests()
79

Subscribers

People subscribed via source and target branches