Update tests/test_param.py
Run Pytest with HTML and XML Test Reports / tests (push) Successful in 26s
Run Pytest with HTML and XML Test Reports / tests (push) Successful in 26s
This commit is contained in:
+32
-1
@@ -69,4 +69,35 @@ class TestDynamic:
|
||||
scenarios = scenarios
|
||||
|
||||
def test_sum_positive(self, x, y):
|
||||
assert (x + y) >= 0
|
||||
assert (x + y) >= 0
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if "val" in metafunc.fixturenames:
|
||||
metafunc.parametrize("val", [10, 20, 30], ids=["ten", "twenty", "thirty"])
|
||||
|
||||
def test_dynamic(val):
|
||||
assert val % 10 == 0
|
||||
|
||||
import pytest
|
||||
|
||||
@pytest.fixture(params=["fire", "water", "earth"], ids=["🔥", "💧", "🌍"])
|
||||
def element(request):
|
||||
return request.param
|
||||
|
||||
def test_element_type(element):
|
||||
assert isinstance(element, str)
|
||||
|
||||
@pytest.mark.parametrize("x", [1, 2])
|
||||
@pytest.mark.parametrize("y", ["a", "b"])
|
||||
def test_combination(x, y):
|
||||
assert isinstance(y, str)
|
||||
|
||||
@pytest.fixture
|
||||
def complex_setup(request):
|
||||
val = request.param
|
||||
return val * 2
|
||||
|
||||
@pytest.mark.parametrize("complex_setup", [1, 2], indirect=True)
|
||||
def test_indirect_fixture(complex_setup):
|
||||
assert complex_setup in [2, 4]
|
||||
Reference in New Issue
Block a user