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:716–728  ·  view source on GitHub ↗

Tests fileinput.lineno() when fileinput._state is not None. Ensure that it invokes fileinput._state.lineno() 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

714 self.assertIsNone(fileinput._state)
715
716 def test_state_is_not_None(self):
717 """Tests fileinput.lineno() when fileinput._state is not None.
718 Ensure that it invokes fileinput._state.lineno() exactly once,
719 returns whatever it returns, and does not modify fileinput._state
720 to point to a different object."""
721 lineno_retval = object()
722 instance = MockFileInput()
723 instance.return_values["lineno"] = lineno_retval
724 fileinput._state = instance
725 retval = fileinput.lineno()
726 self.assertExactlyOneInvocation(instance, "lineno")
727 self.assertIs(retval, lineno_retval)
728 self.assertIs(fileinput._state, instance)
729
730class Test_fileinput_filelineno(BaseFileInputGlobalMethodsTest):
731 """Unit tests for fileinput.filelineno()"""

Callers

nothing calls this directly

Calls 4

MockFileInputClass · 0.85
linenoMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected