MCPcopy Index your code
hub / github.com/ipython/ipython / test_run_ipy_file_attribute

Method test_run_ipy_file_attribute

tests/test_run.py:369–383  ·  view source on GitHub ↗

Test handling of `__file__` attribute in `%run `.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers

nothing calls this directly

Calls 3

mktmpMethod · 0.80
getMethod · 0.80
run_line_magicMethod · 0.80

Tested by

no test coverage detected