~landscape/zope3/newer-from-ztk

« back to all changes in this revision

Viewing changes to src/zope/testing/testrunner/testrunner-ex/sampletestsf.py

  • Committer: Thomas Hervé
  • Date: 2009-09-21 16:46:07 UTC
  • Revision ID: thomas@canonical.com-20090921164607-sky3xhlt02ji80ka
Revert r8: regression with test failures

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
##############################################################################
2
 
#
3
 
# Copyright (c) 2003 Zope Corporation and Contributors.
4
 
# All Rights Reserved.
5
 
#
6
 
# This software is subject to the provisions of the Zope Public License,
7
 
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
8
 
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
 
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
 
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
 
# FOR A PARTICULAR PURPOSE.
12
 
#
13
 
##############################################################################
14
 
 
15
 
import unittest
16
 
from zope.testing import doctest
17
 
 
18
 
x=0
19
 
y=0
20
 
z=0
21
 
 
22
 
class TestA(unittest.TestCase):
23
 
    def setUp(self):
24
 
        global x
25
 
        x = 1
26
 
    def tearDown(self):
27
 
        global x
28
 
        x = 0
29
 
    def test_x1(self):
30
 
        self.assertEqual(x, 1)
31
 
    def test_y0(self):
32
 
        self.assertEqual(y, 0)
33
 
    def test_z0(self):
34
 
        self.assertEqual(z, 0)
35
 
 
36
 
class TestA2(unittest.TestCase):
37
 
    level = 2
38
 
 
39
 
    def setUp(self):
40
 
        global x
41
 
        x = 1
42
 
    def tearDown(self):
43
 
        global x
44
 
        x = 0
45
 
    def test_x1(self):
46
 
        self.assertEqual(x, 1)
47
 
    def test_y0(self):
48
 
        self.assertEqual(y, 0)
49
 
    def test_z0(self):
50
 
        self.assertEqual(z, 0)
51
 
 
52
 
class TestB(unittest.TestCase):
53
 
    def setUp(self):
54
 
        global y
55
 
        y = 1
56
 
    def tearDown(self):
57
 
        global y
58
 
        y = 0
59
 
    def test_y1(self):
60
 
        self.assertEqual(y, 1)
61
 
    def test_x0(self):
62
 
        self.assertEqual(x, 0)
63
 
    def test_z0(self):
64
 
        self.assertEqual(z, 0)
65
 
 
66
 
 
67
 
class TestNotMuch(unittest.TestCase):
68
 
    def test_1(self):
69
 
        pass
70
 
    def test_2(self):
71
 
        pass
72
 
    def test_3(self):
73
 
        pass
74
 
 
75
 
 
76
 
def setUp(test):
77
 
    test.globs['z'] = 1
78
 
 
79
 
 
80
 
def test_y0(self):
81
 
    """
82
 
    >>> y
83
 
    0
84
 
    """
85
 
 
86
 
def test_x0(self):
87
 
    """
88
 
    >>> x
89
 
    0
90
 
    """
91
 
 
92
 
def test_z1(self):
93
 
    """
94
 
    >>> z
95
 
    1
96
 
    """
97
 
 
98
 
import samplelayers
99
 
 
100
 
class Layered:
101
 
 
102
 
    layer = 'samplelayers.Layer1'
103
 
    layerv = '1'
104
 
    layerx = '0'
105
 
 
106
 
class TestA1(unittest.TestCase, Layered):
107
 
 
108
 
    def setUp(self):
109
 
        global x
110
 
        x = 1
111
 
    def tearDown(self):
112
 
        global x
113
 
        x = 0
114
 
    def test_x1(self):
115
 
        self.assertEqual(x, 1)
116
 
        self.assertEqual(samplelayers.layer, self.layerv)
117
 
        self.assertEqual(samplelayers.layerx, self.layerx)
118
 
    def test_y0(self):
119
 
        self.assertEqual(y, 0)
120
 
        self.assertEqual(samplelayers.layer, self.layerv)
121
 
        self.assertEqual(samplelayers.layerx, self.layerx)
122
 
    def test_z0(self):
123
 
        self.assertEqual(z, 0)
124
 
        self.assertEqual(samplelayers.layer, self.layerv)
125
 
        self.assertEqual(samplelayers.layerx, self.layerx)
126
 
 
127
 
class TestB1(unittest.TestCase, Layered):
128
 
    def setUp(self):
129
 
        global y
130
 
        y = 1
131
 
    def tearDown(self):
132
 
        global y
133
 
        y = 0
134
 
    def test_y1(self):
135
 
        self.assertEqual(y, 1)
136
 
        self.assertEqual(samplelayers.layer, self.layerv)
137
 
        self.assertEqual(samplelayers.layerx, self.layerx)
138
 
    def test_x0(self):
139
 
        self.assertEqual(x, 0)
140
 
        self.assertEqual(samplelayers.layer, self.layerv)
141
 
        self.assertEqual(samplelayers.layerx, self.layerx)
142
 
    def test_z0(self):
143
 
        self.assertEqual(z, 0)
144
 
        self.assertEqual(samplelayers.layer, self.layerv)
145
 
        self.assertEqual(samplelayers.layerx, self.layerx)
146
 
 
147
 
 
148
 
class TestNotMuch1(unittest.TestCase, Layered):
149
 
    def test_1(self):
150
 
        self.assertEqual(samplelayers.layer, self.layerv)
151
 
        self.assertEqual(samplelayers.layerx, self.layerx)
152
 
    def test_2(self):
153
 
        self.assertEqual(samplelayers.layer, self.layerv)
154
 
        self.assertEqual(samplelayers.layerx, self.layerx)
155
 
    def test_3(self):
156
 
        self.assertEqual(samplelayers.layer, self.layerv)
157
 
        self.assertEqual(samplelayers.layerx, self.layerx)
158
 
 
159
 
 
160
 
 
161
 
def test_suite():
162
 
    suite = unittest.TestSuite()
163
 
    suite.addTest(unittest.makeSuite(TestA))
164
 
    suite.addTest(unittest.makeSuite(TestA2))
165
 
    suite.addTest(unittest.makeSuite(TestB))
166
 
    suite.addTest(unittest.makeSuite(TestNotMuch))
167
 
    suite.addTest(doctest.DocTestSuite(setUp=setUp))
168
 
    suite.addTest(doctest.DocFileSuite('sampletests.txt', setUp=setUp))
169
 
    suite.addTest(unittest.makeSuite(TestA1))
170
 
    suite.addTest(unittest.makeSuite(TestB1))
171
 
    suite.addTest(unittest.makeSuite(TestNotMuch1))
172
 
    return suite