1
from nose2.tests._common import FunctionalTestCase
4
class TestLayers(FunctionalTestCase):
6
def test_runs_layer_fixtures(self):
10
'--plugin=nose2.plugins.layers')
11
self.assertTestRunOutputMatches(proc, stderr='Ran 8 tests')
12
self.assertEqual(proc.poll(), 0)
14
def test_scenario_fails_without_plugin(self):
18
self.assertTestRunOutputMatches(proc, stderr='Ran 8 tests')
19
self.assertTestRunOutputMatches(proc, stderr=r'FAILED \(failures=7\)')
20
self.assertEqual(proc.poll(), 1)
22
def test_methods_run_once_per_class(self):
24
'scenario/layers_with_inheritance',
26
'--plugin=nose2.plugins.layers')
46
self.assertTestRunOutputMatches(proc, stdout=expected)
47
self.assertEqual(proc.poll(), 0)
49
def test_layer_reporter_output(self):
53
'--plugin=nose2.plugins.layers',
55
expect = r"""test \(test_layers.NoLayer\) ... ok
57
test \(test_layers.Outer\) ... ok
59
test \(test_layers.InnerD\) ... ok
61
test \(test_layers.InnerA\) ... ok
64
test \(test_layers.InnerB_1\) ... ok
66
test \(test_layers.InnerC\) ... ok
67
test2 \(test_layers.InnerC\) ... ok
69
test \(test_layers.InnerA_1\) ... ok""".split("\n")
70
self.assertTestRunOutputMatches(proc, stderr='Ran 8 tests')
72
self.assertTestRunOutputMatches(proc, stderr=line)
73
self.assertEqual(proc.poll(), 0)
75
def test_layer_reporter_error_output(self):
77
'scenario/layers_with_errors',
78
'--plugin=nose2.plugins.layers',
81
r'ERROR: fixture with a value test_err '
82
'\(test_layers_with_errors.Test\)',
83
'ERROR: A test scenario with errors should check for an attribute '
84
'that does not exist and raise an error',
85
r'FAIL: fixture with a value test_fail '
86
'\(test_layers_with_errors.Test\)',
87
'FAIL: A test scenario with errors should check that value == 2 '
90
self.assertTestRunOutputMatches(proc, stderr=line)
91
self.assertEqual(proc.poll(), 1)
93
def test_layers_and_attributes(self):
95
'scenario/layers_and_attributes',
97
'--plugin=nose2.plugins.attrib',
98
'--plugin=nose2.plugins.layers',
101
self.assertTestRunOutputMatches(proc, stderr='Ran 1 test')
102
self.assertEqual(proc.poll(), 0)