【发布时间】:2021-08-30 09:04:34
【问题描述】:
@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]' 寻求帮助。
谁能帮帮我?
【问题讨论】:
标签: pytest pytest-bdd