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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 6 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_wsgiref.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 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 """Unit tests for the with statement specified in PEP 343.""" 3 """Unit tests for the with statement specified in PEP 343."""
4 4
5 5
6 __author__ = "Mike Bland" 6 __author__ = "Mike Bland"
7 __email__ = "mbland at acm dot org" 7 __email__ = "mbland at acm dot org"
8 8
9 import sys 9 import sys
10 import unittest 10 import unittest
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 def assertAfterWithManagerInvariantsWithError(self, mock_manager, 218 def assertAfterWithManagerInvariantsWithError(self, mock_manager,
219 exc_type=None): 219 exc_type=None):
220 self.assertTrue(mock_manager.enter_called) 220 self.assertTrue(mock_manager.enter_called)
221 self.assertTrue(mock_manager.exit_called) 221 self.assertTrue(mock_manager.exit_called)
222 if exc_type is None: 222 if exc_type is None:
223 self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION) 223 self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION)
224 exc_type = type(self.TEST_EXCEPTION) 224 exc_type = type(self.TEST_EXCEPTION)
225 self.assertEqual(mock_manager.exit_args[0], exc_type) 225 self.assertEqual(mock_manager.exit_args[0], exc_type)
226 # Test the __exit__ arguments. Issue #7853 226 # Test the __exit__ arguments. Issue #7853
227 self.assertIsInstance(mock_manager.exit_args[1], exc_type) 227 self.assertIsInstance(mock_manager.exit_args[1], exc_type)
228 self.assertIsNot(mock_manager.exit_args[2], None) 228 self.assertIsNotNone(mock_manager.exit_args[2])
229 229
230 def assertAfterWithGeneratorInvariantsWithError(self, mock_generator): 230 def assertAfterWithGeneratorInvariantsWithError(self, mock_generator):
231 self.assertTrue(mock_generator.yielded) 231 self.assertTrue(mock_generator.yielded)
232 self.assertTrue(mock_generator.stopped) 232 self.assertTrue(mock_generator.stopped)
233 233
234 234
235 class NonexceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin): 235 class NonexceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
236 def testInlineGeneratorSyntax(self): 236 def testInlineGeneratorSyntax(self):
237 with mock_contextmanager_generator(): 237 with mock_contextmanager_generator():
238 pass 238 pass
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 run_unittest(FailureTestCase, NonexceptionalTestCase, 743 run_unittest(FailureTestCase, NonexceptionalTestCase,
744 NestedNonexceptionalTestCase, ExceptionalTestCase, 744 NestedNonexceptionalTestCase, ExceptionalTestCase,
745 NonLocalFlowControlTestCase, 745 NonLocalFlowControlTestCase,
746 AssignmentTargetTestCase, 746 AssignmentTargetTestCase,
747 ExitSwallowsExceptionTestCase, 747 ExitSwallowsExceptionTestCase,
748 NestedWith) 748 NestedWith)
749 749
750 750
751 if __name__ == '__main__': 751 if __name__ == '__main__':
752 test_main() 752 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_winreg.py ('k') | Lib/test/test_wsgiref.py » ('j') | no next file with comments »

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