mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
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:
parent
53c9cdc3fe
commit
e18ea4bca4
1 changed files with 25 additions and 13 deletions
|
@ -85,18 +85,6 @@ test_prepareLocalsData = [
|
||||||
{ # Defaults.
|
{ # Defaults.
|
||||||
"foo": "bla"
|
"foo": "bla"
|
||||||
}
|
}
|
||||||
),
|
|
||||||
( # Section does not exist.
|
|
||||||
{ # Parser data.
|
|
||||||
"some_other_name":
|
|
||||||
{
|
|
||||||
"foo": "bar"
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"profile", # Config section.
|
|
||||||
{ # Defaults.
|
|
||||||
"foo": "baz"
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -114,3 +102,27 @@ def test_prepareLocals(legacy_profile_reader, parser_data, config_section, defau
|
||||||
assert output[key] == parser_data[config_section][key] # If overwritten, must be the overwritten value.
|
assert output[key] == parser_data[config_section][key] # If overwritten, must be the overwritten value.
|
||||||
else:
|
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)
|
Loading…
Add table
Add a link
Reference in a new issue