~ubuntu-branches/debian/squeeze/nose/squeeze

« back to all changes in this revision

Viewing changes to functional_tests/test_attribute_plugin.py

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Marek, Torsten Marek, Gustavo Noronha Silva
  • Date: 2008-06-12 13:39:43 UTC
  • mfrom: (1.2.1 upstream) (2.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080612133943-2q7syp67fwl4on13
Tags: 0.10.3-1

[Torsten Marek]
* New upstream release (Closes: #461994)
* debian/control
  - bump standards version to 3.8.0, no changes necessary
  - add suggestions for python-coverage (Closes: #457053)
  - change dependency on python-setuptools into 
    python-pkg-resources (Closes: #468719)
  - added myself to uploaders

[Gustavo Noronha Silva]
* debian/control:
  - remove -1 from build-dep on setuptools

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import sys
 
3
import unittest
 
4
from nose.plugins.attrib import AttributeSelector
 
5
from nose.plugins import PluginTester
 
6
 
 
7
support = os.path.join(os.path.dirname(__file__), 'support')
 
8
 
 
9
compat_24 = sys.version_info >= (2, 4)
 
10
 
 
11
class TestSimpleAttribute(PluginTester, unittest.TestCase):
 
12
    activate = "-a a"
 
13
    args = ['-v']
 
14
    plugins = [AttributeSelector()]
 
15
    suitepath = os.path.join(support, 'att')
 
16
 
 
17
    def runTest(self):
 
18
        print '*' * 70
 
19
        print str(self.output)
 
20
        print '*' * 70
 
21
        
 
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
 
31
 
 
32
 
 
33
class TestNotSimpleAttribute(PluginTester, unittest.TestCase):
 
34
    activate = "-a !a"
 
35
    args = ['-v']
 
36
    plugins = [AttributeSelector()]
 
37
    suitepath = os.path.join(support, 'att')
 
38
 
 
39
    def runTest(self):
 
40
        print '*' * 70
 
41
        print str(self.output)
 
42
        print '*' * 70
 
43
        
 
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
 
53
 
 
54
 
 
55
class TestAttributeValue(PluginTester, unittest.TestCase):
 
56
    activate = "-a b=2"
 
57
    args = ['-v']
 
58
    plugins = [AttributeSelector()]
 
59
    suitepath = os.path.join(support, 'att')
 
60
 
 
61
    def runTest(self):
 
62
        print '*' * 70
 
63
        print str(self.output)
 
64
        print '*' * 70
 
65
        
 
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
 
75
 
 
76
 
 
77
class TestAttributeArray(PluginTester, unittest.TestCase):
 
78
    activate = "-a d=2"
 
79
    args = ['-v']
 
80
    plugins = [AttributeSelector()]
 
81
    suitepath = os.path.join(support, 'att')
 
82
 
 
83
    def runTest(self):
 
84
        print '*' * 70
 
85
        print str(self.output)
 
86
        print '*' * 70
 
87
        
 
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
 
97
 
 
98
 
 
99
class TestAttributeArrayAnd(PluginTester, unittest.TestCase):
 
100
    activate = "-a d=1,d=2"
 
101
    args = ['-v']
 
102
    plugins = [AttributeSelector()]
 
103
    suitepath = os.path.join(support, 'att')
 
104
 
 
105
    def runTest(self):
 
106
        print '*' * 70
 
107
        print str(self.output)
 
108
        print '*' * 70
 
109
        
 
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
 
119
 
 
120
 
 
121
class TestAttributeArrayOr(PluginTester, unittest.TestCase):
 
122
    activate = "-v"
 
123
    args = ['-a', 'd=1', '-a', 'd=2']
 
124
    plugins = [AttributeSelector()]
 
125
    suitepath = os.path.join(support, 'att')
 
126
 
 
127
    def runTest(self):
 
128
        print '*' * 70
 
129
        print str(self.output)
 
130
        print '*' * 70
 
131
        
 
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
 
141
        
 
142
 
 
143
if compat_24:
 
144
    class TestAttributeEval(PluginTester, unittest.TestCase):
 
145
        activate = "-A c>20"
 
146
        args = ['-v']
 
147
        plugins = [AttributeSelector()]
 
148
        suitepath = os.path.join(support, 'att')
 
149
 
 
150
        def runTest(self):
 
151
            print '*' * 70
 
152
            print str(self.output)
 
153
            print '*' * 70
 
154
 
 
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
 
164
 
 
165
if __name__ == '__main__':
 
166
    #import logging
 
167
    #logging.basicConfig(level=logging.DEBUG)
 
168
    unittest.main()