Test handling of `__file__` attribute in `%run `.
(self)
| 367 | assert file1 == file2 |
| 368 | |
| 369 | def test_run_ipy_file_attribute(self): |
| 370 | """Test handling of `__file__` attribute in `%run <file.ipy>`.""" |
| 371 | src = "t = __file__\n" |
| 372 | self.mktmp(src, ext=".ipy") |
| 373 | _missing = object() |
| 374 | file1 = _ip.user_ns.get("__file__", _missing) |
| 375 | _ip.run_line_magic("run", self.fname) |
| 376 | file2 = _ip.user_ns.get("__file__", _missing) |
| 377 | |
| 378 | # Check that __file__ was equal to the filename in the script's |
| 379 | # namespace. |
| 380 | assert _ip.user_ns["t"] == self.fname |
| 381 | |
| 382 | # Check that __file__ was not leaked back into user_ns. |
| 383 | assert file1 == file2 |
| 384 | |
| 385 | def test_run_formatting(self): |
| 386 | """Test that %run -t -N<N> does not raise a TypeError for N > 1.""" |
nothing calls this directly
no test coverage detected