Skip to content

Commit 8be0683

Browse files
committed
chore: Allow merge to still be used from the command line.
1 parent 4c22069 commit 8be0683

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

src/pytest_plugins/forks/forks.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,14 @@ def pytest_configure(config):
176176
for d in fork_covariant_descriptors:
177177
config.addinivalue_line("markers", f"{d.marker_name}: {d.description}")
178178

179-
single_fork = config.getoption("single_fork")
180-
forks_from = config.getoption("forks_from")
181-
forks_until = config.getoption("forks_until")
179+
def get_fork_option(config, option_name):
180+
"""Post-process get option to allow for external fork conditions."""
181+
option = config.getoption(option_name)
182+
return "Paris" if option == "Merge" else option
183+
184+
single_fork = get_fork_option(config, "single_fork")
185+
forks_from = get_fork_option(config, "forks_from")
186+
forks_until = get_fork_option(config, "forks_until")
182187
show_fork_help = config.getoption("show_fork_help")
183188

184189
all_forks = get_forks()

src/pytest_plugins/forks/tests/test_forks.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,34 @@ def test_all_forks({StateTest.pytest_parameter_name()}):
131131
skipped=0,
132132
errors=0,
133133
)
134+
135+
136+
def test_from_merge_until_merge_option_no_validity_marker(pytester, fork_map):
137+
"""
138+
Test test parametrization with:
139+
- --from Merge command-line option,
140+
- --until Merge command-line option,
141+
- no fork validity marker.
142+
"""
143+
pytester.makepyfile(
144+
f"""
145+
import pytest
146+
147+
def test_all_forks({StateTest.pytest_parameter_name()}):
148+
pass
149+
"""
150+
)
151+
pytester.copy_example(name="pytest.ini")
152+
result = pytester.runpytest("-v", "--from", "Merge", "--until", "Merge")
153+
forks_under_test = forks_from_until(fork_map["Paris"], fork_map["Paris"])
154+
expected_passed = len(forks_under_test) * len(StateTest.fixture_formats())
155+
stdout = "\n".join(result.stdout.lines)
156+
for fork in forks_under_test:
157+
for fixture_format in StateTest.fixture_formats():
158+
assert f":test_all_forks[fork_{fork}-{fixture_format.name.lower()}]" in stdout
159+
result.assert_outcomes(
160+
passed=expected_passed,
161+
failed=0,
162+
skipped=0,
163+
errors=0,
164+
)

0 commit comments

Comments
 (0)