@scenario('../features/config.feature', 'Loading a valid config')
def test_config():
pass
@given("I have provided a valid pylon config",target_fixture="pylon_config")
def pylon_config():
input_data = {
}
return input_data
@when("The configuration is loaded")
def excute_pylon_config(pylon_config):
createFilterPattern(pylon_config)
@then("It should be enriched with the expected FilterPatterns")
def no_error_message(pylon_config):
test_data1= {
}
test_data_2 = {
}
result = pylon_config
@scenario('../features/config.feature', 'Missing usagePlan section')
def test_missing_usageplan():
pass
@given("I have provided a pylon config with a missing key",target_fixture="pylon_config_missing_usageplan")
def pylon_config_missing_usageplan():
input_data = {
'metricFilters': {
'defaults': {
'xyz': []
}
}
}
return input_data
@when("The configuration is loaded")
def excute_pylon_config_missing_usageplan(pylon_config_missing_usageplan):
try:
createFilterPattern(pylon_config_missing_usageplan)
except KeyError:
pass
@then("I should receive an exception")
def error_message_pylon_config_missing_usageplan(pylon_config_missing_usageplan):
print(pylon_config_missing_usageplan)
我已经编写了多个测试用例,并在 @given 场景中指定了 target_fixture。
在运行测试用例时,它会抛出一个错误
找不到夹具“pylon_config_missing_usageplan”
可用的固定装置:缓存、capfd、capfdbinary、caplog、capsys、capsysbinary、doctest_namespace、monkeypatch、pylon_config、pytestbdd_given_我提供了一个缺少密钥的 pylon 配置,pytestbdd_given_我提供了一个有效的 pylon 配置,pytestbdd_given_trace,pytestbdd_then_我应该收到一个异常,pytestbdd_then_它应该使用预期的 FilterPatterns、pytestbdd_then_trace、pytestbdd_when_加载配置、pytestbdd_when_trace、pytestconfig、record_property、record_testsuite_property、record_xml_attribute、recwarn、tmp_path、tmp_path_factory、tmpdir、tmpdir_factory 使用“pytest --fixtures [testpath]”获取帮助。
有人可以帮我吗?