Tests fileinput.fileno() when fileinput._state is not None. Ensure that it invokes fileinput._state.fileno() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.
(self)
| 768 | self.assertIsNone(fileinput._state) |
| 769 | |
| 770 | def test_state_is_not_None(self): |
| 771 | """Tests fileinput.fileno() when fileinput._state is not None. |
| 772 | Ensure that it invokes fileinput._state.fileno() exactly once, |
| 773 | returns whatever it returns, and does not modify fileinput._state |
| 774 | to point to a different object.""" |
| 775 | fileno_retval = object() |
| 776 | instance = MockFileInput() |
| 777 | instance.return_values["fileno"] = fileno_retval |
| 778 | instance.fileno_retval = fileno_retval |
| 779 | fileinput._state = instance |
| 780 | retval = fileinput.fileno() |
| 781 | self.assertExactlyOneInvocation(instance, "fileno") |
| 782 | self.assertIs(retval, fileno_retval) |
| 783 | self.assertIs(fileinput._state, instance) |
| 784 | |
| 785 | class Test_fileinput_isfirstline(BaseFileInputGlobalMethodsTest): |
| 786 | """Unit tests for fileinput.isfirstline()""" |
nothing calls this directly
no test coverage detected