Set we can run mutiprocesgin without messing up up main namespace Note that import `nose.tools as nt` modify the values sys.module['__mp_main__'] so we need to temporarily set it to None to test the issue.
()
| 637 | |
| 638 | |
| 639 | def test_multiprocessing_run(): |
| 640 | """Set we can run mutiprocesgin without messing up up main namespace |
| 641 | |
| 642 | Note that import `nose.tools as nt` modify the values |
| 643 | sys.module['__mp_main__'] so we need to temporarily set it to None to test |
| 644 | the issue. |
| 645 | """ |
| 646 | with TemporaryDirectory() as td: |
| 647 | mpm = sys.modules.get("__mp_main__") |
| 648 | sys.modules["__mp_main__"] = None |
| 649 | try: |
| 650 | path = pjoin(td, "test.py") |
| 651 | with open(path, "w", encoding="utf-8") as f: |
| 652 | f.write("import multiprocessing\nprint('hoy')") |
| 653 | with capture_output() as io: |
| 654 | _ip.run_line_magic("run", path) |
| 655 | _ip.run_cell("i_m_undefined") |
| 656 | out = io.stdout |
| 657 | assert "hoy" in out |
| 658 | assert "AttributeError" not in out |
| 659 | assert "NameError" in out |
| 660 | assert out.count("---->") == 1 |
| 661 | except: |
| 662 | raise |
| 663 | finally: |
| 664 | sys.modules["__mp_main__"] = mpm |
| 665 | |
| 666 | |
| 667 | def test_script_tb(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…