4
from nose.plugins.attrib import AttributeSelector
5
from nose.plugins import PluginTester
7
support = os.path.join(os.path.dirname(__file__), 'support')
9
compat_24 = sys.version_info >= (2, 4)
11
class TestSimpleAttribute(PluginTester, unittest.TestCase):
14
plugins = [AttributeSelector()]
15
suitepath = os.path.join(support, 'att')
19
print str(self.output)
22
assert 'test_attr.test_one ... ok' in self.output
23
assert 'test_attr.test_two ... ok' in self.output
24
assert 'TestClass.test_class_one ... ok' in self.output
25
assert 'TestClass.test_class_two ... ok' in self.output
26
assert 'TestClass.test_class_three ... ok' in self.output
27
assert 'test_three' not in self.output
28
assert 'test_case_two' not in self.output
29
assert 'test_case_one' not in self.output
30
assert 'test_case_three' not in self.output
33
class TestNotSimpleAttribute(PluginTester, unittest.TestCase):
36
plugins = [AttributeSelector()]
37
suitepath = os.path.join(support, 'att')
41
print str(self.output)
44
assert 'test_attr.test_one ... ok' not in self.output
45
assert 'test_attr.test_two ... ok' not in self.output
46
assert 'TestClass.test_class_one ... ok' not in self.output
47
assert 'TestClass.test_class_two ... ok' not in self.output
48
assert 'TestClass.test_class_three ... ok' not in self.output
49
assert 'test_three' in self.output
50
assert 'test_case_two' in self.output
51
assert 'test_case_one' in self.output
52
assert 'test_case_three' in self.output
55
class TestAttributeValue(PluginTester, unittest.TestCase):
58
plugins = [AttributeSelector()]
59
suitepath = os.path.join(support, 'att')
63
print str(self.output)
66
assert 'test_attr.test_one ... ok' not in self.output
67
assert 'test_attr.test_two ... ok' not in self.output
68
assert 'test_attr.test_three ... ok' not in self.output
69
assert 'TestClass.test_class_one ... ok' not in self.output
70
assert 'TestClass.test_class_two ... ok' in self.output
71
assert 'TestClass.test_class_three ... ok' not in self.output
72
assert 'test_case_two' in self.output
73
assert 'test_case_one' in self.output
74
assert 'test_case_three' in self.output
77
class TestAttributeArray(PluginTester, unittest.TestCase):
80
plugins = [AttributeSelector()]
81
suitepath = os.path.join(support, 'att')
85
print str(self.output)
88
assert 'test_attr.test_one ... ok' in self.output
89
assert 'test_attr.test_two ... ok' in self.output
90
assert 'test_attr.test_three ... ok' not in self.output
91
assert 'TestClass.test_class_one ... ok' not in self.output
92
assert 'TestClass.test_class_two ... ok' not in self.output
93
assert 'TestClass.test_class_three ... ok' not in self.output
94
assert 'test_case_two' not in self.output
95
assert 'test_case_one' not in self.output
96
assert 'test_case_three' not in self.output
99
class TestAttributeArrayAnd(PluginTester, unittest.TestCase):
100
activate = "-a d=1,d=2"
102
plugins = [AttributeSelector()]
103
suitepath = os.path.join(support, 'att')
107
print str(self.output)
110
assert 'test_attr.test_one ... ok' in self.output
111
assert 'test_attr.test_two ... ok' not in self.output
112
assert 'test_attr.test_three ... ok' not in self.output
113
assert 'TestClass.test_class_one ... ok' not in self.output
114
assert 'TestClass.test_class_two ... ok' not in self.output
115
assert 'TestClass.test_class_three ... ok' not in self.output
116
assert 'test_case_two' not in self.output
117
assert 'test_case_one' not in self.output
118
assert 'test_case_three' not in self.output
121
class TestAttributeArrayOr(PluginTester, unittest.TestCase):
123
args = ['-a', 'd=1', '-a', 'd=2']
124
plugins = [AttributeSelector()]
125
suitepath = os.path.join(support, 'att')
129
print str(self.output)
132
assert 'test_attr.test_one ... ok' in self.output
133
assert 'test_attr.test_two ... ok' in self.output
134
assert 'test_attr.test_three ... ok' in self.output
135
assert 'TestClass.test_class_one ... ok' not in self.output
136
assert 'TestClass.test_class_two ... ok' not in self.output
137
assert 'TestClass.test_class_three ... ok' not in self.output
138
assert 'test_case_two' not in self.output
139
assert 'test_case_one' not in self.output
140
assert 'test_case_three' not in self.output
144
class TestAttributeEval(PluginTester, unittest.TestCase):
147
plugins = [AttributeSelector()]
148
suitepath = os.path.join(support, 'att')
152
print str(self.output)
155
assert 'test_attr.test_one ... ok' not in self.output
156
assert 'test_attr.test_two ... ok' not in self.output
157
assert 'test_attr.test_three ... ok' not in self.output
158
assert 'TestClass.test_class_one ... ok' not in self.output
159
assert 'TestClass.test_class_two ... ok' not in self.output
160
assert 'TestClass.test_class_three ... ok' not in self.output
161
assert 'test_case_two' in self.output
162
assert 'test_case_one' not in self.output
163
assert 'test_case_three' not in self.output
165
if __name__ == '__main__':
167
#logging.basicConfig(level=logging.DEBUG)