~landscape/zope3/newer-from-ztk

« back to all changes in this revision

Viewing changes to src/zope/testing/testrunner/testrunner-ex/sample1/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 TestB(unittest.TestCase):
37
 
    def setUp(self):
38
 
        global y
39
 
        y = 1
40
 
    def tearDown(self):
41
 
        global y
42
 
        y = 0
43
 
    def test_y1(self):
44
 
        self.assertEqual(y, 1)
45
 
    def test_x0(self):
46
 
        self.assertEqual(x, 0)
47
 
    def test_z0(self):
48
 
        self.assertEqual(z, 0)
49
 
 
50
 
 
51
 
class TestNotMuch(unittest.TestCase):
52
 
    def test_1(self):
53
 
        pass
54
 
    def test_2(self):
55
 
        pass
56
 
    def test_3(self):
57
 
        pass
58
 
 
59
 
def setUp(test):
60
 
    test.globs['z'] = 1
61
 
 
62
 
def test_y0(self):
63
 
    """
64
 
    >>> y
65
 
    0
66
 
    """
67
 
 
68
 
def test_x0(self):
69
 
    """
70
 
    >>> x
71
 
    0
72
 
    """
73
 
 
74
 
def test_z1(self):
75
 
    """
76
 
    >>> z
77
 
    1
78
 
    """
79
 
 
80
 
def test_suite():
81
 
    suite = unittest.TestSuite()
82
 
    suite.addTest(unittest.makeSuite(TestA))
83
 
    suite.addTest(unittest.makeSuite(TestB))
84
 
    suite.addTest(unittest.makeSuite(TestNotMuch))
85
 
    suite.addTest(doctest.DocTestSuite(setUp=setUp))
86
 
    suite.addTest(doctest.DocFileSuite('../sampletests.txt',
87
 
                                       setUp=setUp))
88
 
    return suite