summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test/test_runner.py
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2010-05-07 16:00:30 (GMT)
committerMichael Foord <fuzzyman@voidspace.org.uk>2010-05-07 16:00:30 (GMT)
commit56fdb7545363c5b1e2987b08fa9b271dd289ce66 (patch)
tree6e300097aa2ef4a8957ad6fb3112d54f4301ad30 /Lib/unittest/test/test_runner.py
parent4a8cf3c50b58c48ae5f08e2fad4e99a207d8553e (diff)
downloadcpython-56fdb7545363c5b1e2987b08fa9b271dd289ce66.zip
cpython-56fdb7545363c5b1e2987b08fa9b271dd289ce66.tar.gz
cpython-56fdb7545363c5b1e2987b08fa9b271dd289ce66.tar.bz2
Merged revisions 80920 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80920 | michael.foord | 2010-05-07 17:52:05 +0200 (Fri, 07 May 2010) | 1 line Adding tests for unittest command line handling of buffer, catchbreak and failfast. ........
Diffstat (limited to 'Lib/unittest/test/test_runner.py')
-rw-r--r--Lib/unittest/test/test_runner.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py
index 4486e68..a7bd1a3 100644
--- a/Lib/unittest/test/test_runner.py
+++ b/Lib/unittest/test/test_runner.py
@@ -114,6 +114,52 @@ class TestCleanUp(unittest.TestCase):
class Test_TextTestRunner(unittest.TestCase):
"""Tests for TextTestRunner."""
+ def test_init(self):
+ runner = unittest.TextTestRunner()
+ self.assertFalse(runner.failfast)
+ self.assertFalse(runner.buffer)
+ self.assertEqual(runner.verbosity, 1)
+ self.assertTrue(runner.descriptions)
+ self.assertEqual(runner.resultclass, unittest.TextTestResult)
+
+
+ def testBufferAndFailfast(self):
+ class Test(unittest.TestCase):
+ def testFoo(self):
+ pass
+ result = unittest.TestResult()
+ runner = unittest.TextTestRunner(stream=io.StringIO(), failfast=True,
+ buffer=True)
+ # Use our result object
+ runner._makeResult = lambda: result
+ runner.run(Test('testFoo'))
+
+ self.assertTrue(result.failfast)
+ self.assertTrue(result.buffer)
+
+ def testRunnerRegistersResult(self):
+ class Test(unittest.TestCase):
+ def testFoo(self):
+ pass
+ originalRegisterResult = unittest.runner.registerResult
+ def cleanup():
+ unittest.runner.registerResult = originalRegisterResult
+ self.addCleanup(cleanup)
+
+ result = unittest.TestResult()
+ runner = unittest.TextTestRunner(stream=io.StringIO())
+ # Use our result object
+ runner._makeResult = lambda: result
+
+ self.wasRegistered = 0
+ def fakeRegisterResult(thisResult):
+ self.wasRegistered += 1
+ self.assertEqual(thisResult, result)
+ unittest.runner.registerResult = fakeRegisterResult
+
+ runner.run(unittest.TestSuite())
+ self.assertEqual(self.wasRegistered, 1)
+
def test_works_with_result_without_startTestRun_stopTestRun(self):
class OldTextResult(ResultWithNoStartTestRunStopTestRun):
separator2 = ''