(self)
| 940 | """Unit tests for fileinput.hook_encoded()""" |
| 941 | |
| 942 | def test(self): |
| 943 | encoding = object() |
| 944 | errors = object() |
| 945 | result = fileinput.hook_encoded(encoding, errors=errors) |
| 946 | |
| 947 | fake_open = InvocationRecorder() |
| 948 | original_open = builtins.open |
| 949 | builtins.open = fake_open |
| 950 | try: |
| 951 | filename = object() |
| 952 | mode = object() |
| 953 | open_result = result(filename, mode) |
| 954 | finally: |
| 955 | builtins.open = original_open |
| 956 | |
| 957 | self.assertEqual(fake_open.invocation_count, 1) |
| 958 | |
| 959 | args, kwargs = fake_open.last_invocation |
| 960 | self.assertIs(args[0], filename) |
| 961 | self.assertIs(args[1], mode) |
| 962 | self.assertIs(kwargs.pop('encoding'), encoding) |
| 963 | self.assertIs(kwargs.pop('errors'), errors) |
| 964 | self.assertFalse(kwargs) |
| 965 | |
| 966 | def test_errors(self): |
| 967 | with open(TESTFN, 'wb') as f: |
nothing calls this directly
no test coverage detected