diff options
author | Ghostkeeper <rubend@tutanota.com> | 2021-03-08 18:53:38 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2021-03-08 18:53:48 +0300 |
commit | fde9449358f027b85d731d4b40471235e95505b5 (patch) | |
tree | 1d7849d506a6b5756f122cde9e13a80c61c1e3fd /tests | |
parent | cbafac6133335169c291e1b851955017e4979900 (diff) |
Add test to ensure that no definitions define new settings
See the documentation of the test.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Settings/TestDefinitionContainer.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/Settings/TestDefinitionContainer.py b/tests/Settings/TestDefinitionContainer.py index ec9e132b24..f532aca031 100644 --- a/tests/Settings/TestDefinitionContainer.py +++ b/tests/Settings/TestDefinitionContainer.py @@ -227,4 +227,20 @@ def test_extruderMatch(file_path: str): # Also test if the extruder_nr setting is properly overridden. if "overrides" not in doc or "extruder_nr" not in doc["overrides"] or "default_value" not in doc["overrides"]["extruder_nr"]: assert position == "0" # Default to 0 is allowed. - assert doc["overrides"]["extruder_nr"]["default_value"] == int(position)
\ No newline at end of file + assert doc["overrides"]["extruder_nr"]["default_value"] == int(position) + +@pytest.mark.parametrize("file_path", definition_filepaths) +def test_noNewSettings(file_path: str): + """ + Tests that a printer definition doesn't define any new settings. + + Settings that are not common to all printers can cause Cura to crash, for instance when the setting is saved in a + profile and that profile is then used in a different printer. + :param file_path: A path to a definition file to test. + """ + filename = os.path.basename(file_path) + if filename == "fdmprinter.def.json" or filename == "fdmextruder.def.json": + return # FDMPrinter and FDMExtruder, being the basis for all printers and extruders, are allowed to define new settings since they will be available for all printers then. + with open(file_path, encoding = "utf-8") as f: + doc = json.load(f) + assert "settings" not in doc
\ No newline at end of file |