OLD | NEW |
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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 with self.Dummy(gobble=True) as a, self.ExitRaises(): | 727 with self.Dummy(gobble=True) as a, self.ExitRaises(): |
728 body_executed = True | 728 body_executed = True |
729 self.assertTrue(a.enter_called) | 729 self.assertTrue(a.enter_called) |
730 self.assertTrue(a.exit_called) | 730 self.assertTrue(a.exit_called) |
731 self.assertTrue(body_executed) | 731 self.assertTrue(body_executed) |
732 self.assertNotEqual(a.exc_info[0], None) | 732 self.assertNotEqual(a.exc_info[0], None) |
733 | 733 |
734 def testEnterReturnsTuple(self): | 734 def testEnterReturnsTuple(self): |
735 with self.Dummy(value=(1,2)) as (a1, a2), \ | 735 with self.Dummy(value=(1,2)) as (a1, a2), \ |
736 self.Dummy(value=(10, 20)) as (b1, b2): | 736 self.Dummy(value=(10, 20)) as (b1, b2): |
737 self.assertEquals(1, a1) | 737 self.assertEqual(1, a1) |
738 self.assertEquals(2, a2) | 738 self.assertEqual(2, a2) |
739 self.assertEquals(10, b1) | 739 self.assertEqual(10, b1) |
740 self.assertEquals(20, b2) | 740 self.assertEqual(20, b2) |
741 | 741 |
742 def test_main(): | 742 def test_main(): |
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() |
OLD | NEW |