Merge lp:~bac/zope.testing/list-tests into lp:~launchpad/zope.testing/3.9.4-fork

Proposed by Brad Crittenden
Status: Merged
Approved by: Gary Poster
Approved revision: 31
Merged at revision: 30
Proposed branch: lp:~bac/zope.testing/list-tests
Merge into: lp:~launchpad/zope.testing/3.9.4-fork
Diff against target: 101 lines (+10/-11)
4 files modified
setup.py (+1/-1)
src/zope/testing/testrunner/find.py (+7/-7)
src/zope/testing/testrunner/formatter.py (+2/-2)
src/zope/testing/testrunner/listing.py (+0/-1)
To merge this branch: bzr merge lp:~bac/zope.testing/list-tests
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+109007@code.launchpad.net

Commit message

Make the testrunner output test.id() instead of str(test). Also allows tests to be discovered by pattern matching against the id property.

Description of the change

In Launchpad, some doctests are registered multiple times using different layers, etc. To the test runner they appear the same as they have the same id. Launchpad now gives them different ids but they still reference the same path, which is what the testrunner uses to report and discover tests.

This change causes the testrunner to output test.id() instead of str(test). It also allows tests to be discovered by pattern matching against the id property.

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Thank you Brad, and thanks for the cleanup along the way.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2012-05-30 11:59:41 +0000
3+++ setup.py 2012-06-06 17:53:32 +0000
4@@ -85,7 +85,7 @@
5
6 setup(
7 name='zope.testing',
8- version = '3.9.4-p6',
9+ version = '3.9.4-p8',
10 url='http://pypi.python.org/pypi/zope.testing',
11 license='ZPL 2.1',
12 description='Zope testing framework, including the testrunner script.',
13
14=== modified file 'src/zope/testing/testrunner/find.py'
15--- src/zope/testing/testrunner/find.py 2010-06-04 14:58:44 +0000
16+++ src/zope/testing/testrunner/find.py 2012-06-06 17:53:32 +0000
17@@ -34,10 +34,10 @@
18 >>> class Options(object):
19 ... post_mortem = False
20 >>> options = Options()
21-
22+
23 Normally the StartUpFailure just acts as an empty test suite to satisfy
24 the test runner and statistics:
25-
26+
27 >>> s = StartUpFailure(options, None, None)
28 >>> isinstance(s,unittest.TestCase)
29 True
30@@ -48,9 +48,9 @@
31
32 ...then the the StartUpFailure will start the debugger and stop
33 the test run after the debugger quits.
34-
35+
36 To simulate this, we need an exception and its associated
37- exc_info:
38+ exc_info:
39
40 >>> import sys
41 >>> try:
42@@ -60,7 +60,7 @@
43
44 To simulate the user pressing 'c' and hitting return in the
45 debugger, we use a FakeInputContinueGenerator:
46-
47+
48 >>> from zope.testing.testrunner.runner import FakeInputContinueGenerator
49 >>> old_stdin = sys.stdin
50 >>> sys.stdin = FakeInputContinueGenerator()
51@@ -68,7 +68,7 @@
52 Now we can see the EndRun exception that is raised by the
53 postmortem debugger to indicate that debugging is finished and the
54 test run should be terminated:
55-
56+
57 >>> try:
58 ... StartUpFailure(options, None, exc_info)
59 ... finally:
60@@ -362,7 +362,7 @@
61 else:
62 if level <= options.at_level:
63 for pat in options.test:
64- if pat(str(suite)):
65+ if pat(str(suite)) or pat(suite.id()):
66 yield (suite, layer)
67 break
68
69
70=== modified file 'src/zope/testing/testrunner/formatter.py'
71--- src/zope/testing/testrunner/formatter.py 2012-05-30 11:59:41 +0000
72+++ src/zope/testing/testrunner/formatter.py 2012-06-06 17:53:32 +0000
73@@ -175,7 +175,7 @@
74 """Report a list of test names."""
75 print "Listing %s tests:" % layer_name
76 for test in tests:
77- print ' ', test
78+ print ' ', test.id()
79
80 def garbage(self, garbage):
81 """Report garbage generated by tests."""
82@@ -278,7 +278,7 @@
83 sys.stdout.write('\n')
84
85 if self.verbose > 1:
86- s = str(test)
87+ s = str(test.id())
88 sys.stdout.write(' ')
89 sys.stdout.write(s)
90 self.test_width += len(s) + 1
91
92=== modified file 'src/zope/testing/testrunner/listing.py'
93--- src/zope/testing/testrunner/listing.py 2010-06-04 14:58:44 +0000
94+++ src/zope/testing/testrunner/listing.py 2012-06-06 17:53:32 +0000
95@@ -31,6 +31,5 @@
96 self.runner.failed = False
97
98 def report(self):
99- layers = self.runner.tests_by_layer_name
100 for layer_name, layer, tests in self.runner.ordered_layers():
101 self.runner.options.output.list_of_tests(tests, layer_name)

Subscribers

People subscribed via source and target branches