vendor/Five/1.2b-r20590

view testing/testrunner-ex/sample1/sample11/sampletests.py @ 0:3673ed425f80

Vendor import of Five 1.2b+ (r20590)
author fguillaume
date Fri, 02 Dec 2005 20:25:42 +0000
parents
children
line source
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 ##############################################################################
15 import unittest
16 from Products.Five.testing import doctest
18 x=0
19 y=0
20 z=0
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)
36 class TestA3(unittest.TestCase):
38 level = 3
40 def setUp(self):
41 global x
42 x = 1
43 def tearDown(self):
44 global x
45 x = 0
46 def test_x1(self):
47 self.assertEqual(x, 1)
48 def test_y0(self):
49 self.assertEqual(y, 0)
50 def test_z0(self):
51 self.assertEqual(z, 0)
53 class TestB(unittest.TestCase):
54 def setUp(self):
55 global y
56 y = 1
57 def tearDown(self):
58 global y
59 y = 0
60 def test_y1(self):
61 self.assertEqual(y, 1)
62 def test_x0(self):
63 self.assertEqual(x, 0)
64 def test_z0(self):
65 self.assertEqual(z, 0)
67 class TestB2(unittest.TestCase):
68 level = 2
70 def setUp(self):
71 global y
72 y = 1
73 def tearDown(self):
74 global y
75 y = 0
76 def test_y1(self):
77 self.assertEqual(y, 1)
78 def test_x0(self):
79 self.assertEqual(x, 0)
80 def test_z0(self):
81 self.assertEqual(z, 0)
84 class TestNotMuch(unittest.TestCase):
85 def test_1(self):
86 pass
87 def test_2(self):
88 pass
89 def test_3(self):
90 pass
92 def setUp(test):
93 test.globs['z'] = 1
95 def test_y0(self):
96 """
97 >>> y
98 0
99 """
101 def test_x0(self):
102 """
103 >>> x
104 0
105 """
107 def test_z1(self):
108 """
109 >>> z
110 1
111 """
113 def test_suite():
114 suite = unittest.TestSuite()
115 suite.addTest(unittest.makeSuite(TestA))
116 suite.addTest(unittest.makeSuite(TestA3))
117 suite.addTest(unittest.makeSuite(TestB))
118 suite.addTest(unittest.makeSuite(TestB2))
119 suite.addTest(unittest.makeSuite(TestNotMuch))
120 suite.addTest(doctest.DocTestSuite(setUp=setUp))
121 suite.addTest(doctest.DocFileSuite('../../sampletests.txt',
122 setUp=setUp))
123 return suite