4
We can select which layers to run using the --layer option:
6
>>> import os.path, sys
7
>>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
9
... '--path', directory_with_tests,
10
... '--tests-pattern', '^sampletestsf?$',
13
>>> sys.argv = 'test --layer 112 --layer Unit'.split()
14
>>> from zope.testing import testrunner
15
>>> testrunner.run_internal(defaults)
16
Running samplelayers.Layer112 tests:
17
Set up samplelayers.Layerx in N.NNN seconds.
18
Set up samplelayers.Layer1 in N.NNN seconds.
19
Set up samplelayers.Layer11 in N.NNN seconds.
20
Set up samplelayers.Layer112 in N.NNN seconds.
21
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
22
Running zope.testing.testrunner.layer.UnitTests tests:
23
Tear down samplelayers.Layer112 in N.NNN seconds.
24
Tear down samplelayers.Layerx in N.NNN seconds.
25
Tear down samplelayers.Layer11 in N.NNN seconds.
26
Tear down samplelayers.Layer1 in N.NNN seconds.
27
Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
28
Ran 192 tests with 0 failures and 0 errors in N.NNN seconds.
29
Tearing down left over layers:
30
Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
31
Total: 226 tests, 0 failures, 0 errors in N.NNN seconds.
35
We can also specify that we want to run only the unit tests:
37
>>> sys.argv = 'test -u'.split()
38
>>> testrunner.run_internal(defaults)
39
Running zope.testing.testrunner.layer.UnitTests tests:
40
Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
41
Ran 192 tests with 0 failures and 0 errors in N.NNN seconds.
42
Tearing down left over layers:
43
Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
47
Or that we want to run all of the tests except for the unit tests:
49
>>> sys.argv = 'test -f'.split()
50
>>> testrunner.run_internal(defaults)
51
Running samplelayers.Layer1 tests:
52
Set up samplelayers.Layer1 in N.NNN seconds.
53
Ran 9 tests with 0 failures and 0 errors in N.NNN seconds.
54
Running samplelayers.Layer11 tests:
55
Set up samplelayers.Layer11 in N.NNN seconds.
56
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
57
Running samplelayers.Layer111 tests:
58
Set up samplelayers.Layerx in N.NNN seconds.
59
Set up samplelayers.Layer111 in N.NNN seconds.
60
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
61
Running samplelayers.Layer112 tests:
62
Tear down samplelayers.Layer111 in N.NNN seconds.
63
Set up samplelayers.Layer112 in N.NNN seconds.
64
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
65
Running samplelayers.Layer12 tests:
66
Tear down samplelayers.Layer112 in N.NNN seconds.
67
Tear down samplelayers.Layerx in N.NNN seconds.
68
Tear down samplelayers.Layer11 in N.NNN seconds.
69
Set up samplelayers.Layer12 in N.NNN seconds.
70
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
71
Running samplelayers.Layer121 tests:
72
Set up samplelayers.Layer121 in N.NNN seconds.
73
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
74
Running samplelayers.Layer122 tests:
75
Tear down samplelayers.Layer121 in N.NNN seconds.
76
Set up samplelayers.Layer122 in N.NNN seconds.
77
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
78
Tearing down left over layers:
79
Tear down samplelayers.Layer122 in N.NNN seconds.
80
Tear down samplelayers.Layer12 in N.NNN seconds.
81
Tear down samplelayers.Layer1 in N.NNN seconds.
82
Total: 213 tests, 0 failures, 0 errors in N.NNN seconds.
85
Or we can explicitly say that we want both unit and non-unit tests.
87
>>> sys.argv = 'test -uf'.split()
88
>>> testrunner.run_internal(defaults)
89
Running samplelayers.Layer1 tests:
90
Set up samplelayers.Layer1 in N.NNN seconds.
91
Ran 9 tests with 0 failures and 0 errors in N.NNN seconds.
92
Running samplelayers.Layer11 tests:
93
Set up samplelayers.Layer11 in N.NNN seconds.
94
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
95
Running samplelayers.Layer111 tests:
96
Set up samplelayers.Layerx in N.NNN seconds.
97
Set up samplelayers.Layer111 in N.NNN seconds.
98
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
99
Running samplelayers.Layer112 tests:
100
Tear down samplelayers.Layer111 in N.NNN seconds.
101
Set up samplelayers.Layer112 in N.NNN seconds.
102
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
103
Running samplelayers.Layer12 tests:
104
Tear down samplelayers.Layer112 in N.NNN seconds.
105
Tear down samplelayers.Layerx in N.NNN seconds.
106
Tear down samplelayers.Layer11 in N.NNN seconds.
107
Set up samplelayers.Layer12 in N.NNN seconds.
108
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
109
Running samplelayers.Layer121 tests:
110
Set up samplelayers.Layer121 in N.NNN seconds.
111
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
112
Running samplelayers.Layer122 tests:
113
Tear down samplelayers.Layer121 in N.NNN seconds.
114
Set up samplelayers.Layer122 in N.NNN seconds.
115
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
116
Running zope.testing.testrunner.layer.UnitTests tests:
117
Tear down samplelayers.Layer122 in N.NNN seconds.
118
Tear down samplelayers.Layer12 in N.NNN seconds.
119
Tear down samplelayers.Layer1 in N.NNN seconds.
120
Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
121
Ran 192 tests with 0 failures and 0 errors in N.NNN seconds.
122
Tearing down left over layers:
123
Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
124
Total: 405 tests, 0 failures, 0 errors in N.NNN seconds.
127
It is possible to force the layers to run in subprocesses and parallelize them.
129
>>> sys.argv = [testrunner_script, '-j2']
130
>>> testrunner.run_internal(defaults)
131
Running samplelayers.Layer1 tests:
132
Set up samplelayers.Layer1 in N.NNN seconds.
133
Ran 9 tests with 0 failures and 0 errors in N.NNN seconds.
134
Running samplelayers.Layer11 tests:
135
Running in a subprocess.
136
Set up samplelayers.Layer1 in N.NNN seconds.
137
Set up samplelayers.Layer11 in N.NNN seconds.
138
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
139
Running samplelayers.Layer111 tests:
140
Running in a subprocess.
141
Set up samplelayers.Layerx in N.NNN seconds.
142
Set up samplelayers.Layer1 in N.NNN seconds.
143
Set up samplelayers.Layer11 in N.NNN seconds.
144
Set up samplelayers.Layer111 in N.NNN seconds.
145
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
146
Running samplelayers.Layer112 tests:
147
Running in a subprocess.
148
Set up samplelayers.Layerx in N.NNN seconds.
149
Set up samplelayers.Layer1 in N.NNN seconds.
150
Set up samplelayers.Layer11 in N.NNN seconds.
151
Set up samplelayers.Layer112 in N.NNN seconds.
152
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
153
Running samplelayers.Layer12 tests:
154
Running in a subprocess.
155
Set up samplelayers.Layer1 in N.NNN seconds.
156
Set up samplelayers.Layer12 in N.NNN seconds.
157
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
158
Running samplelayers.Layer121 tests:
159
Running in a subprocess.
160
Set up samplelayers.Layer1 in N.NNN seconds.
161
Set up samplelayers.Layer12 in N.NNN seconds.
162
Set up samplelayers.Layer121 in N.NNN seconds.
163
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
164
Running samplelayers.Layer122 tests:
165
Running in a subprocess.
166
Set up samplelayers.Layer1 in N.NNN seconds.
167
Set up samplelayers.Layer12 in N.NNN seconds.
168
Set up samplelayers.Layer122 in N.NNN seconds.
169
Ran 34 tests with 0 failures and 0 errors in N.NNN seconds.
170
Running zope.testing.testrunner.layer.UnitTests tests:
171
Running in a subprocess.
172
Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
173
Ran 192 tests with 0 failures and 0 errors in N.NNN seconds.
174
Total: 405 tests, 0 failures, 0 errors in N.NNN seconds.