Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(160957)

Side by Side Diff: Lib/test/test_with.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_winreg.py ('k') | Lib/test/test_xdrlib.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Unit tests for the with statement specified in PEP 343.""" 1 """Unit tests for the with statement specified in PEP 343."""
2 2
3 3
4 __author__ = "Mike Bland" 4 __author__ = "Mike Bland"
5 __email__ = "mbland at acm dot org" 5 __email__ = "mbland at acm dot org"
6 6
7 import sys 7 import sys
8 import unittest 8 import unittest
9 from collections import deque 9 from collections import deque
10 from contextlib import _GeneratorContextManager, contextmanager 10 from contextlib import _GeneratorContextManager, contextmanager
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 def assertAfterWithManagerInvariantsWithError(self, mock_manager, 216 def assertAfterWithManagerInvariantsWithError(self, mock_manager,
217 exc_type=None): 217 exc_type=None):
218 self.assertTrue(mock_manager.enter_called) 218 self.assertTrue(mock_manager.enter_called)
219 self.assertTrue(mock_manager.exit_called) 219 self.assertTrue(mock_manager.exit_called)
220 if exc_type is None: 220 if exc_type is None:
221 self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION) 221 self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION)
222 exc_type = type(self.TEST_EXCEPTION) 222 exc_type = type(self.TEST_EXCEPTION)
223 self.assertEqual(mock_manager.exit_args[0], exc_type) 223 self.assertEqual(mock_manager.exit_args[0], exc_type)
224 # Test the __exit__ arguments. Issue #7853 224 # Test the __exit__ arguments. Issue #7853
225 self.assertIsInstance(mock_manager.exit_args[1], exc_type) 225 self.assertIsInstance(mock_manager.exit_args[1], exc_type)
226 self.assertIsNot(mock_manager.exit_args[2], None) 226 self.assertIsNotNone(mock_manager.exit_args[2])
227 227
228 def assertAfterWithGeneratorInvariantsWithError(self, mock_generator): 228 def assertAfterWithGeneratorInvariantsWithError(self, mock_generator):
229 self.assertTrue(mock_generator.yielded) 229 self.assertTrue(mock_generator.yielded)
230 self.assertTrue(mock_generator.stopped) 230 self.assertTrue(mock_generator.stopped)
231 231
232 232
233 class NonexceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin): 233 class NonexceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
234 def testInlineGeneratorSyntax(self): 234 def testInlineGeneratorSyntax(self):
235 with mock_contextmanager_generator(): 235 with mock_contextmanager_generator():
236 pass 236 pass
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 run_unittest(FailureTestCase, NonexceptionalTestCase, 741 run_unittest(FailureTestCase, NonexceptionalTestCase,
742 NestedNonexceptionalTestCase, ExceptionalTestCase, 742 NestedNonexceptionalTestCase, ExceptionalTestCase,
743 NonLocalFlowControlTestCase, 743 NonLocalFlowControlTestCase,
744 AssignmentTargetTestCase, 744 AssignmentTargetTestCase,
745 ExitSwallowsExceptionTestCase, 745 ExitSwallowsExceptionTestCase,
746 NestedWith) 746 NestedWith)
747 747
748 748
749 if __name__ == '__main__': 749 if __name__ == '__main__':
750 test_main() 750 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_winreg.py ('k') | Lib/test/test_xdrlib.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+