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

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

660 self.assertIsNone(fileinput._state)
661
662 def test_state_is_not_None(self):
663 """Tests fileinput.nextfile() when fileinput._state is not None.
664 Ensure that it invokes fileinput._state.nextfile() exactly once,
665 returns whatever it returns, and does not modify fileinput._state
666 to point to a different object."""
667 nextfile_retval = object()
668 instance = MockFileInput()
669 instance.return_values["nextfile"] = nextfile_retval
670 fileinput._state = instance
671 retval = fileinput.nextfile()
672 self.assertExactlyOneInvocation(instance, "nextfile")
673 self.assertIs(retval, nextfile_retval)
674 self.assertIs(fileinput._state, instance)
675
676class Test_fileinput_filename(BaseFileInputGlobalMethodsTest):
677 """Unit tests for fileinput.filename()"""

Callers

nothing calls this directly

Calls 4

MockFileInputClass · 0.85
nextfileMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected