/
testrunner-discovery.txt
71 lines (61 loc) · 2.68 KB
/
testrunner-discovery.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Automatically discovering tests
===============================
You can explicitly specify which tests to run by providing a function that
returns a unittest.TestSuite in the test modules (the name of the function can
be configured with the --suite-name parameter, it defaults to 'test_suite'). If
no such function is present, testrunner will use all classes in the module that
inherit from unittest.TestCase as tests:
>>> import os, sys
>>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
>>> from zope import testrunner
>>> defaults = [
... '--path', directory_with_tests,
... '--tests-pattern', '^sampletestsf?$',
... ]
>>> sys.argv = ['test',
... '--tests-pattern', '^sampletests_discover$',
... ]
>>> testrunner.run(defaults)
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
Tearing down left over layers:
Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
False
If the module neither provides a TestSuite nor has discoverable tests,
testrunner will exit with an error to prevent acidentally missing test cases:
>>> sys.argv = ['test',
... '--tests-pattern', '^sampletests_discover_notests$',
... ]
>>> testrunner.run(defaults)
Test-module import failures:
<BLANKLINE>
Module: sample1.sampletests_discover_notests
<BLANKLINE>
TypeError: Module sample1.sampletests_discover_notests does not define any tests
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
Test-modules with import problems:
sample1.sampletests_discover_notests
Total: 0 tests, 0 failures, 0 errors and 0 skipped in 0.000 seconds.
True
You can explicitly specify which tests to run by providing a function that
returns a unittest.TestSuite in the test modules (the name of the function can
be configured with the --suite-name parameter, it defaults to 'test_suite'). If
no such function is present, testrunner will use all classes in the module that
inherit from unittest.TestCase as tests:
>>> import os, sys
>>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
>>> from zope import testrunner
>>> defaults = [
... ]
>>> sys.argv = ['test',
... ]
>>> testrunner.run(defaults)
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
Ran 2 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
Tearing down left over layers:
Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
False