| 518 | nt.assert_equal(_ip.user_ns['a'], test_opts) |
| 519 | |
| 520 | def 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 | |
| 540 | def test_run_tb(): |