Test handling of `__file__` attribute in `%run .py`.
(self)
| 351 | assert _ip.user_ns["u"] == "Ўт№Ф" |
| 352 | |
| 353 | def test_run_py_file_attribute(self): |
| 354 | """Test handling of `__file__` attribute in `%run <file>.py`.""" |
| 355 | src = "t = __file__\n" |
| 356 | self.mktmp(src) |
| 357 | _missing = object() |
| 358 | file1 = _ip.user_ns.get("__file__", _missing) |
| 359 | _ip.run_line_magic("run", self.fname) |
| 360 | file2 = _ip.user_ns.get("__file__", _missing) |
| 361 | |
| 362 | # Check that __file__ was equal to the filename in the script's |
| 363 | # namespace. |
| 364 | assert _ip.user_ns["t"] == self.fname |
| 365 | |
| 366 | # Check that __file__ was not leaked back into user_ns. |
| 367 | assert file1 == file2 |
| 368 | |
| 369 | def test_run_ipy_file_attribute(self): |
| 370 | """Test handling of `__file__` attribute in `%run <file.ipy>`.""" |
nothing calls this directly
no test coverage detected