File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333import pickle
3434import sys
3535import threading
36+ from pathlib import Path
3637
3738import pytest
3839from datafusion import col , lit
3940
4041from . import _pickle_multiprocessing_helpers as helpers
4142
43+ # `pytest --import-mode=importlib` (used in CI) does not prepend the test
44+ # parent directory to `sys.path`; pytest loads `tests` via its own importlib
45+ # hook. multiprocessing forkserver / spawn workers receive only the parent's
46+ # `sys.path` snapshot, not pytest's hook, so they fail to import
47+ # `tests._pickle_multiprocessing_helpers` with `ModuleNotFoundError: No module
48+ # named 'tests'`. Ensure the parent directory of the `tests` package is on
49+ # `sys.path` so workers can resolve it the standard way. Fork start method is
50+ # unaffected (inherits the already-imported module object).
51+ _TESTS_PARENT = str (Path (__file__ ).resolve ().parent .parent )
52+ if _TESTS_PARENT not in sys .path :
53+ sys .path .insert (0 , _TESTS_PARENT )
54+
4255
4356@contextlib .contextmanager
4457def _snapshot_on_hang (label : str , fire_after_seconds : float = 30.0 ):
You can’t perform that action at this time.
0 commit comments