summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test/test_runner.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-03-20 19:16:47 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-03-20 19:16:47 (GMT)
commitc9b3ef2df06818f055e555c1d23e3ff2d5bf2d74 (patch)
treee157db4bfab86a28530fb2a4ea77c075003f98aa /Lib/unittest/test/test_runner.py
parenta612176c9c0c82138e797c2abadb6ef65e97b44a (diff)
downloadcpython-c9b3ef2df06818f055e555c1d23e3ff2d5bf2d74.zip
cpython-c9b3ef2df06818f055e555c1d23e3ff2d5bf2d74.tar.gz
cpython-c9b3ef2df06818f055e555c1d23e3ff2d5bf2d74.tar.bz2
Issue #16997: unittest.TestCase now provides a subTest() context manager to procedurally generate, in an easy way, small test instances.
Diffstat (limited to 'Lib/unittest/test/test_runner.py')
-rw-r--r--Lib/unittest/test/test_runner.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py
index aed1e76..8f5cd2e 100644
--- a/Lib/unittest/test/test_runner.py
+++ b/Lib/unittest/test/test_runner.py
@@ -5,6 +5,7 @@ import pickle
import subprocess
import unittest
+from unittest.case import _Outcome
from .support import LoggingResult, ResultWithNoStartTestRunStopTestRun
@@ -42,12 +43,8 @@ class TestCleanUp(unittest.TestCase):
def testNothing(self):
pass
- class MockOutcome(object):
- success = True
- errors = []
-
test = TestableTest('testNothing')
- test._outcomeForDoCleanups = MockOutcome
+ outcome = test._outcome = _Outcome()
exc1 = Exception('foo')
exc2 = Exception('bar')
@@ -61,9 +58,10 @@ class TestCleanUp(unittest.TestCase):
test.addCleanup(cleanup2)
self.assertFalse(test.doCleanups())
- self.assertFalse(MockOutcome.success)
+ self.assertFalse(outcome.success)
- (Type1, instance1, _), (Type2, instance2, _) = reversed(MockOutcome.errors)
+ ((_, (Type1, instance1, _)),
+ (_, (Type2, instance2, _))) = reversed(outcome.errors)
self.assertEqual((Type1, instance1), (Exception, exc1))
self.assertEqual((Type2, instance2), (Exception, exc2))