| 6418 | START_METHODS = {"forkserver", "spawn"} |
| 6419 | |
| 6420 | def setUp(self): |
| 6421 | self._orig_sys_path = list(sys.path) |
| 6422 | self._temp_dir = tempfile.mkdtemp(prefix="test_sys_path-") |
| 6423 | self._mod_name = "unique_test_mod" |
| 6424 | module_path = os.path.join(self._temp_dir, f"{self._mod_name}.py") |
| 6425 | with open(module_path, "w", encoding="utf-8") as mod: |
| 6426 | mod.write("# A simple test module\n") |
| 6427 | sys.path[:] = [p for p in sys.path if p] # remove any existing ""s |
| 6428 | sys.path.insert(0, self._temp_dir) |
| 6429 | sys.path.insert(0, "") # Replaced with an abspath in child. |
| 6430 | self.assertIn(self.start_method, self.START_METHODS) |
| 6431 | self._ctx = multiprocessing.get_context(self.start_method) |
| 6432 | |
| 6433 | def tearDown(self): |
| 6434 | sys.path[:] = self._orig_sys_path |