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)
| 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 | |
| 703 | class Test_fileinput_lineno(BaseFileInputGlobalMethodsTest): |
| 704 | """Unit tests for fileinput.lineno()""" |
nothing calls this directly
no test coverage detected