Skip to content

Commit e345087

Browse files
committed
debt: parameter option overrides unit tests
1 parent 2031724 commit e345087

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

allure-python-commons-test/src/result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ def with_trace_contains(string):
221221
return has_entry('trace', contains_string(string))
222222

223223

224-
def with_excluded():
225-
return has_entry('excluded', True)
224+
def with_excluded(excluded: bool = True):
225+
return has_entry('excluded', excluded)
226226

227227

228228
def with_mode(mode):

tests/allure_pytest/acceptance/parametrization/parametrization_test.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from hamcrest import assert_that, has_entry, ends_with, all_of
23
from tests.allure_pytest.pytest_runner import AllurePytestRunner
34

@@ -181,6 +182,30 @@ def test_dynamic_parameter_excluded(allure_pytest_runner: AllurePytestRunner):
181182
)
182183

183184

185+
@pytest.mark.xfail(reason="Known issue: cannot explicitly set excluded flag to False")
186+
def test_dynamic_parameter_excluded_false(allure_pytest_runner: AllurePytestRunner):
187+
"""
188+
>>> import allure
189+
190+
>>> def test_parameter_excluded():
191+
... allure.dynamic.parameter("param1", "param-value", excluded=False)
192+
"""
193+
194+
allure_results = allure_pytest_runner.run_docstring()
195+
196+
assert_that(
197+
allure_results,
198+
has_test_case(
199+
"test_parameter_excluded",
200+
has_parameter(
201+
"param1",
202+
"'param-value'",
203+
with_excluded(False)
204+
)
205+
)
206+
)
207+
208+
184209
def test_dynamic_parameter_mode(allure_pytest_runner: AllurePytestRunner):
185210
"""
186211
>>> import allure
@@ -225,6 +250,58 @@ def test_dynamic_parameter_override(allure_pytest_runner: AllurePytestRunner):
225250
)
226251

227252

253+
@pytest.mark.xfail(reason="Known issue: cannot override excluded flag")
254+
def test_dynamic_parameter_override_excluded(allure_pytest_runner: AllurePytestRunner):
255+
"""
256+
>>> import pytest
257+
... import allure
258+
259+
>>> @pytest.mark.parametrize("param1", [object()], ids=["param-id"])
260+
... def test_parameter_override(param1):
261+
... allure.dynamic.parameter("param1", "readable-value", excluded=True)
262+
"""
263+
264+
allure_results = allure_pytest_runner.run_docstring()
265+
266+
assert_that(
267+
allure_results,
268+
has_test_case(
269+
"test_parameter_override[param-id]",
270+
has_parameter(
271+
"param1",
272+
"'readable-value'",
273+
with_excluded(),
274+
),
275+
)
276+
)
277+
278+
279+
@pytest.mark.xfail(reason="Known issue: cannot override mode")
280+
def test_dynamic_parameter_override_mode(allure_pytest_runner: AllurePytestRunner):
281+
"""
282+
>>> import pytest
283+
... import allure
284+
285+
>>> @pytest.mark.parametrize("param1", [object()], ids=["param-id"])
286+
... def test_parameter_override(param1):
287+
... allure.dynamic.parameter("param1", "readable-value", mode=allure.parameter_mode.MASKED)
288+
"""
289+
290+
allure_results = allure_pytest_runner.run_docstring()
291+
292+
assert_that(
293+
allure_results,
294+
has_test_case(
295+
"test_parameter_override[param-id]",
296+
has_parameter(
297+
"param1",
298+
"'readable-value'",
299+
with_mode("masked"),
300+
),
301+
)
302+
)
303+
304+
228305
def test_dynamic_parameter_override_from_fixture(
229306
allure_pytest_runner: AllurePytestRunner
230307
):

0 commit comments

Comments
 (0)