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
|
Finding tests in all modules
============================
Normally, nose only looks for tests in modules whose names match testMatch. By
default that means modules with 'test' or 'Test' at the start of the name
after an underscore (_) or dash (-) or other non-alphanumeric character.
If you want to collect tests from all modules, use the ``--all-modules``
command line argument to activate the :doc:`allmodules plugin
<../../plugins/allmodules>`.
.. Note ::
The function :func:`nose.plugins.plugintest.run` reformats test result
output to remove timings, which will vary from run to run, and
redirects the output to stdout.
>>> from nose.plugins.plugintest import run_buffered as run
..
>>> import os
>>> support = os.path.join(os.path.dirname(__file__), 'support')
>>> argv = [__file__, '-v', support]
The target directory contains a test module and a normal module.
>>> support_files = [d for d in os.listdir(support)
... if not d.startswith('.')
... and d.endswith('.py')]
>>> support_files.sort()
>>> support_files
['mod.py', 'test.py']
When run without ``--all-modules``, only the test module is examined for tests.
>>> run(argv=argv)
test.test ... ok
<BLANKLINE>
----------------------------------------------------------------------
Ran 1 test in ...s
<BLANKLINE>
OK
When ``--all-modules`` is active, both modules are examined.
>>> from nose.plugins.allmodules import AllModules
>>> argv = [__file__, '-v', '--all-modules', support]
>>> run(argv=argv, plugins=[AllModules()]) # doctest: +REPORT_NDIFF
mod.test ... ok
mod.test_fails ... FAIL
test.test ... ok
<BLANKLINE>
======================================================================
FAIL: mod.test_fails
----------------------------------------------------------------------
Traceback (most recent call last):
...
AssertionError: This test fails
<BLANKLINE>
----------------------------------------------------------------------
Ran 3 tests in ...s
<BLANKLINE>
FAILED (failures=1)
|