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

Method test_state_is_not_None

Lib/test/test_fileinput.py:689–701  ·  view source on GitHub ↗

Tests fileinput.filename() when fileinput._state is not None. Ensure that it invokes fileinput._state.filename() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.

(self)

Source from the content-addressed store, hash-verified

687 self.assertIsNone(fileinput._state)
688
689 def test_state_is_not_None(self):
690 """Tests fileinput.filename() when fileinput._state is not None.
691 Ensure that it invokes fileinput._state.filename() exactly once,
692 returns whatever it returns, and does not modify fileinput._state
693 to point to a different object."""
694 filename_retval = object()
695 instance = MockFileInput()
696 instance.return_values["filename"] = filename_retval
697 fileinput._state = instance
698 retval = fileinput.filename()
699 self.assertExactlyOneInvocation(instance, "filename")
700 self.assertIs(retval, filename_retval)
701 self.assertIs(fileinput._state, instance)
702
703class Test_fileinput_lineno(BaseFileInputGlobalMethodsTest):
704 """Unit tests for fileinput.lineno()"""

Callers

nothing calls this directly

Calls 4

MockFileInputClass · 0.85
filenameMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected