Skip to content

Commit 8bdca01

Browse files
authored
Pre-release version 1.0
Simple fix for args with dynamic scheduler
2 parents 59bbfda + 3876045 commit 8bdca01

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

pytest_parallel/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,14 @@ def is_master_process(comm, scheduler):
6464
def spawn_master_process(global_comm):
6565
if not is_dyn_master_process(global_comm):
6666
error_codes = []
67-
inter_comm = global_comm.Spawn(
68-
sys.argv[0], args=sys.argv[1:], maxprocs=1, errcodes=error_codes
69-
)
67+
if sys.argv[0].endswith(".py"):
68+
inter_comm = global_comm.Spawn(
69+
sys.executable, args=sys.argv, maxprocs=1, errcodes=error_codes
70+
)
71+
else:
72+
inter_comm = global_comm.Spawn(
73+
sys.argv[0], args=sys.argv[1:], maxprocs=1, errcodes=error_codes
74+
)
7075
for error_code in error_codes:
7176
if error_code != 0:
7277
assert 0

test/test_pytest_parallel.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ def run_pytest_parallel_test(test_name, n_workers, scheduler, capfd, suffix=""):
6969
f.write(captured.out)
7070
if not ref_match(output_file_name):
7171
print("err: ", captured.err)
72-
print("out: ", captured.out.replace(os.linesep, '\n'))
72+
print("out: ", captured.out.replace(os.linesep, "\n"))
7373
assert ref_match(output_file_name)
7474
# cmd += f' > {output_file_path} 2> {stderr_file_path}' # redirections. stderr is actually not very useful (since the tests errors are reported in stdout by PyTest)
7575

7676

77-
param_scheduler = ["sequential", "static", "dynamic"] if sys.platform != "win32" else ["sequential", "static"]
78-
77+
param_scheduler = (
78+
["sequential", "static", "dynamic"]
79+
if sys.platform != "win32"
80+
else ["sequential", "static"]
81+
)
82+
7983

8084
@pytest.mark.parametrize("scheduler", param_scheduler)
8185
class TestPytestParallel:

0 commit comments

Comments
 (0)