MCPcopy Index your code
hub / github.com/python/cpython / test

Method test

Lib/test/test_fileinput.py:942–964  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 5

InvocationRecorderClass · 0.85
assertFalseMethod · 0.80
assertEqualMethod · 0.45
assertIsMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected