File tree Expand file tree Collapse file tree 4 files changed +30
-3
lines changed
test/openjd/adaptor_runtime/integ Expand file tree Collapse file tree 4 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 1+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
3+ import os
4+ import sys
5+ from pathlib import Path
6+
7+ # This ensures test modules can be imported in subprocesses
8+ def pytest_configure (config ):
9+ test_path = Path (__file__ ).parent / "test" / "openjd" / "adaptor_runtime" / "integ"
10+ if test_path .exists ():
11+ sys .path .append (str (test_path ))
12+ os .environ ["PYTHONPATH" ] = os .pathsep .join ([
13+ os .environ .get ("PYTHONPATH" , "" ),
14+ str (test_path )
15+ ]).strip (os .pathsep )
Original file line number Diff line number Diff line change 11# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
3- from .__main__ import main
43from .adaptor import CommandAdaptorExample
54
6- __all__ = ["CommandAdaptorExample" , "main" ]
5+ __all__ = ["CommandAdaptorExample" ]
Original file line number Diff line number Diff line change 2929
3030mod_path = (Path (__file__ ).parent .parent ).resolve ()
3131sys .path .append (str (mod_path ))
32+
33+ # Fix for pytest 8.3+ on Windows - ensure module path is properly set in environment
3234if (_pypath := os .environ .get ("PYTHONPATH" )) is not None :
3335 os .environ ["PYTHONPATH" ] = os .pathsep .join ((_pypath , str (mod_path )))
3436else :
3537 os .environ ["PYTHONPATH" ] = str (mod_path )
38+
39+ # Add the module path to PYTHONPATH for subprocesses
40+ os .environ ["PYTEST_XDIST_WORKER_PYTHONPATH" ] = str (mod_path )
41+
3642from AdaptorExample import AdaptorExample # noqa: E402
3743
3844
Original file line number Diff line number Diff line change 2020
2121mod_path = Path (__file__ ).parent .resolve ()
2222sys .path .append (str (mod_path ))
23+
24+ # Fix for pytest 8.3+ on Windows - ensure module path is properly set in environment
25+ path_sep = ";" if sys .platform == "win32" else ":"
2326if (_pypath := os .environ .get ("PYTHONPATH" )) is not None :
24- os .environ ["PYTHONPATH" ] = ":" .join (( _pypath , str (mod_path )) )
27+ os .environ ["PYTHONPATH" ] = path_sep .join ([ _pypath , str (mod_path )] )
2528else :
2629 os .environ ["PYTHONPATH" ] = str (mod_path )
30+
31+ # Add the module path to PYTHONPATH for subprocesses
32+ os .environ ["PYTEST_XDIST_WORKER_PYTHONPATH" ] = str (mod_path )
33+
2734from CommandAdaptorExample import CommandAdaptorExample # noqa: E402
2835
2936
You can’t perform that action at this time.
0 commit comments