summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2010-05-09 09:59:35 (GMT)
committerMichael Foord <fuzzyman@voidspace.org.uk>2010-05-09 09:59:35 (GMT)
commitffa2e4ee5548d8e158057b99c9680adf56255c1b (patch)
tree9743e0e1058131f2e5965fece7d9fc4a16c8e35f /Lib/unittest
parent04afd1fb521b70b33e0824c5f768322c47011565 (diff)
downloadcpython-ffa2e4ee5548d8e158057b99c9680adf56255c1b.zip
cpython-ffa2e4ee5548d8e158057b99c9680adf56255c1b.tar.gz
cpython-ffa2e4ee5548d8e158057b99c9680adf56255c1b.tar.bz2
Merged revisions 81022 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81022 | michael.foord | 2010-05-09 11:58:25 +0200 (Sun, 09 May 2010) | 1 line Adding a test for unittest.BaseTestSuite. ........
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/test/test_suite.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_suite.py b/Lib/unittest/test/test_suite.py
index ab2e16e..47b57de 100644
--- a/Lib/unittest/test/test_suite.py
+++ b/Lib/unittest/test/test_suite.py
@@ -1,5 +1,6 @@
import unittest
+import sys
from .support import LoggingResult, TestEquality
@@ -300,5 +301,49 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite.run(unittest.TestResult())
+
+ def test_basetestsuite(self):
+ class Test(unittest.TestCase):
+ wasSetUp = False
+ wasTornDown = False
+ @classmethod
+ def setUpClass(cls):
+ cls.wasSetUp = True
+ @classmethod
+ def tearDownClass(cls):
+ cls.wasTornDown = True
+ def testPass(self):
+ pass
+ def testFail(self):
+ fail
+ class Module(object):
+ wasSetUp = False
+ wasTornDown = False
+ @staticmethod
+ def setUpModule():
+ Module.wasSetUp = True
+ @staticmethod
+ def tearDownModule():
+ Module.wasTornDown = True
+
+ Test.__module__ = 'Module'
+ sys.modules['Module'] = Module
+ self.addCleanup(sys.modules.pop, 'Module')
+
+ suite = unittest.BaseTestSuite()
+ suite.addTests([Test('testPass'), Test('testFail')])
+ self.assertEqual(suite.countTestCases(), 2)
+
+ result = unittest.TestResult()
+ suite.run(result)
+ self.assertFalse(Module.wasSetUp)
+ self.assertFalse(Module.wasTornDown)
+ self.assertFalse(Test.wasSetUp)
+ self.assertFalse(Test.wasTornDown)
+ self.assertEqual(len(result.errors), 1)
+ self.assertEqual(len(result.failures), 0)
+ self.assertEqual(result.testsRun, 2)
+
+
if __name__ == '__main__':
unittest.main()