✔ .pytest
¶
If you want to combine a feature also with tests, you want to use the .pytest()
functionality. The pytest
expects a function (not a callable) which it can execute. This is exactly what the .pytest()
function of feature_flag
provides.
Additionally, you can specify if the decorated test should pass/fail.
In [1]:
Copied!
import ipytest
ipytest.autoconfig()
from fastfeatureflag.feature_flag import feature_flag
@feature_flag().pytest()
def test_deactive_for_pytest():
assert False
@feature_flag("on").pytest()
def test_active_for_pytest():
assert True
import ipytest
ipytest.autoconfig()
from fastfeatureflag.feature_flag import feature_flag
@feature_flag().pytest()
def test_deactive_for_pytest():
assert False
@feature_flag("on").pytest()
def test_active_for_pytest():
assert True
In [2]:
Copied!
ipytest.run()
ipytest.run()
.. [100%] 2 passed in 0.01s
Out[2]:
<ExitCode.OK: 0>
Last update:
October 28, 2023
Created: October 28, 2023
Created: October 28, 2023