elegant-florist-94385
03/06/2025, 12:40 PM__defaults__(
{
"python_tests": dict(
extra_env_vars=parametrize(
A_B=("FEATURE_A=true", "FEATURE_B=true"),
A_noB=("FEATURE_A=true", "FEATURE_B=false"),
noA_B=("FEATURE_A=false", "FEATURE_B=true"),
noA_noB=("FEATURE_A=false", "FEATURE_B=false"),
),
),
},
)
Because I want to run my tests against all the different combinations of feature flags. (Some tests are skipped based on the feature flags, some test alternate behaviours, and some are just to make sure that the code under test doesn't do anything different if feature flags are enabled).
However, there is plenty of code where the feature flags don't matter. In fact, there are lots of files that do not even have `src/python/config/feature_flags.py`(single place where all env vars are imported into the application code) as a transitive dependency. Since they cannot be affected by feature flags, there is no need to run them multiple times.
Is there any way I can do something like:
extra_env_vars=parametrize(...) if "//src/python/config/feature_flags.py" in target.dependencies else Nonesquare-psychiatrist-19087
03/06/2025, 12:55 PMsquare-psychiatrist-19087
03/06/2025, 12:56 PMsquare-psychiatrist-19087
03/06/2025, 1:01 PMimport pytest
@pytest.fixture(params=[True, False], ids=["A", "noA"])
def feature_a(request):
return request.param
@pytest.fixture(params=[True, False], ids=["B", "noB"])
def feature_b(request):
return request.param
def test_something(feature_a, feature_b):
assert True
test_something.py::test_something[A-B] PASSED
test_something.py::test_something[A-noB] PASSED
test_something.py::test_something[noA-B] PASSED
test_something.py::test_something[noA-noB] PASSEDelegant-florist-94385
03/06/2025, 1:21 PMsquare-psychiatrist-19087
03/06/2025, 2:04 PMsquare-psychiatrist-19087
03/06/2025, 2:05 PMsquare-psychiatrist-19087
03/06/2025, 3:08 PMimport pytest
@pytest.fixture(params=[True, False], ids=["A", "noA"], autouse=True)
def feature_a(request):
return request.param
@pytest.fixture(params=[True, False], ids=["B", "noB"], autouse=True)
def feature_b(request):
return request.param
def test_something():
assert True
some_test.py::test_something[A-B] PASSED
some_test.py::test_something[A-noB] PASSED
some_test.py::test_something[noA-B] PASSED
some_test.py::test_something[noA-noB] PASSED