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)
| 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 | |
| 676 | class Test_fileinput_filename(BaseFileInputGlobalMethodsTest): |
| 677 | """Unit tests for fileinput.filename()""" |
nothing calls this directly
no test coverage detected