Tests fileinput.filename() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state
(self)
| 677 | """Unit tests for fileinput.filename()""" |
| 678 | |
| 679 | def test_state_is_None(self): |
| 680 | """Tests fileinput.filename() when fileinput._state is None. |
| 681 | Ensure that it raises RuntimeError with a meaningful error message |
| 682 | and does not modify fileinput._state""" |
| 683 | fileinput._state = None |
| 684 | with self.assertRaises(RuntimeError) as cm: |
| 685 | fileinput.filename() |
| 686 | self.assertEqual(("no active input()",), cm.exception.args) |
| 687 | self.assertIsNone(fileinput._state) |
| 688 | |
| 689 | def test_state_is_not_None(self): |
| 690 | """Tests fileinput.filename() when fileinput._state is not None. |
nothing calls this directly
no test coverage detected