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

Method test_run_py_file_attribute

tests/test_run.py:353–367  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

mktmpMethod · 0.80
getMethod · 0.80
run_line_magicMethod · 0.80

Tested by

no test coverage detected