Set we can run mutiprocesgin without messing up up main namespace Note that import `nose.tools as nt` mdify the value s sys.module['__mp_main__'] so wee need to temporarily set it to None to test the issue.
()
| 560 | |
| 561 | |
| 562 | def test_multiprocessing_run(): |
| 563 | """Set we can run mutiprocesgin without messing up up main namespace |
| 564 | |
| 565 | Note that import `nose.tools as nt` mdify the value s |
| 566 | sys.module['__mp_main__'] so wee need to temporarily set it to None to test |
| 567 | the issue. |
| 568 | """ |
| 569 | with TemporaryDirectory() as td: |
| 570 | mpm = sys.modules.get('__mp_main__') |
| 571 | assert mpm is not None |
| 572 | sys.modules['__mp_main__'] = None |
| 573 | try: |
| 574 | path = pjoin(td, 'test.py') |
| 575 | with open(path, 'w') as f: |
| 576 | f.write("import multiprocessing\nprint('hoy')") |
| 577 | with capture_output() as io: |
| 578 | _ip.run_line_magic('run', path) |
| 579 | _ip.run_cell("i_m_undefined") |
| 580 | out = io.stdout |
| 581 | nt.assert_in("hoy", out) |
| 582 | nt.assert_not_in("AttributeError", out) |
| 583 | nt.assert_in("NameError", out) |
| 584 | nt.assert_equal(out.count("---->"), 1) |
| 585 | except: |
| 586 | raise |
| 587 | finally: |
| 588 | sys.modules['__mp_main__'] = mpm |
| 589 | |
| 590 | @dec.knownfailureif(sys.platform == 'win32', "writes to io.stdout aren't captured on Windows") |
| 591 | def test_script_tb(): |
nothing calls this directly
no test coverage detected