Expect a NoSectionError if testing with a section that is missing

We want to get that error in order to debug.

Contributes to issue CURA-5929.
This commit is contained in:
Ghostkeeper 2018-11-12 13:47:24 +01:00
parent 53c9cdc3fe
commit e18ea4bca4
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -85,18 +85,6 @@ test_prepareLocalsData = [
{ # Defaults.
"foo": "bla"
}
),
( # Section does not exist.
{ # Parser data.
"some_other_name":
{
"foo": "bar"
},
},
"profile", # Config section.
{ # Defaults.
"foo": "baz"
}
)
]
@ -113,4 +101,28 @@ def test_prepareLocals(legacy_profile_reader, parser_data, config_section, defau
if key in parser_data[config_section]:
assert output[key] == parser_data[config_section][key] # If overwritten, must be the overwritten value.
else:
assert output[key] == defaults[key] # Otherwise must be equal to the default.
assert output[key] == defaults[key] # Otherwise must be equal to the default.
test_prepareLocalsNoSectionErrorData = [
( # Section does not exist.
{ # Parser data.
"some_other_name":
{
"foo": "bar"
},
},
"profile", # Config section.
{ # Defaults.
"foo": "baz"
}
)
]
## Test cases where a key error is expected.
@pytest.mark.parametrize("parser_data, config_section, defaults", test_prepareLocalsNoSectionErrorData)
def test_prepareLocalsNoSectionError(legacy_profile_reader, parser_data, config_section, defaults):
parser = configparser.ConfigParser()
parser.read_dict(parser_data)
with pytest.raises(configparser.NoSectionError):
legacy_profile_reader.prepareLocals(parser, config_section, defaults)