MCPcopy Create free account
hub / github.com/ipython/ipython / test_run__name__

Function test_run__name__

IPython/core/tests/test_run.py:520–537  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

518 nt.assert_equal(_ip.user_ns['a'], test_opts)
519
520def test_run__name__():
521 with TemporaryDirectory() as td:
522 path = pjoin(td, 'foo.py')
523 with open(path, 'w') as f:
524 f.write("q = __name__")
525
526 _ip.user_ns.pop('q', None)
527 _ip.magic('run {}'.format(path))
528 nt.assert_equal(_ip.user_ns.pop('q'), '__main__')
529
530 _ip.magic('run -n {}'.format(path))
531 nt.assert_equal(_ip.user_ns.pop('q'), 'foo')
532
533 try:
534 _ip.magic('run -i -n {}'.format(path))
535 nt.assert_equal(_ip.user_ns.pop('q'), 'foo')
536 finally:
537 _ip.magic('reset -f')
538
539
540def test_run_tb():

Callers

nothing calls this directly

Calls 4

popMethod · 0.80
writeMethod · 0.45
magicMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected