From bbb26c2cea7364d59a8a7bb230e7c7c57de6564d Mon Sep 17 00:00:00 2001 From: Harry Dalton Date: Thu, 1 Sep 2022 17:34:51 +0100 Subject: [PATCH] Confirm split functions can handle unbounded conditions with absent keys As we make an effort to support conditions with "minimum" or "maximum" absent, as well as with "minimum" or "maximum" None, this commit confirms that the split functions can handle these to some degree also. --- Tests/designspaceLib/split_test.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Tests/designspaceLib/split_test.py b/Tests/designspaceLib/split_test.py index f0d4f9bcd..d7c7b246d 100644 --- a/Tests/designspaceLib/split_test.py +++ b/Tests/designspaceLib/split_test.py @@ -160,13 +160,15 @@ def test_convert5to4(datadir, tmpdir, test_ds, expected_vfs): @pytest.mark.parametrize( ["unbounded_condition"], [ + ({"name": "Weight", "minimum": 500},), + ({"name": "Weight", "maximum": 500},), ({"name": "Weight", "minimum": 500, "maximum": None},), ({"name": "Weight", "minimum": None, "maximum": 500},), ], ) def test_optional_min_max(unbounded_condition): """Check that split functions can handle conditions that are partially - unbounded without tripping over the None values.""" + unbounded without tripping over None values and missing keys.""" doc = DesignSpaceDocument() doc.addAxisDescriptor( @@ -185,6 +187,14 @@ def test_optional_min_max(unbounded_condition): @pytest.mark.parametrize( ["condition", "expected_set"], [ + ( + {"name": "axis", "minimum": 0.5}, + {"axis": Range(minimum=0.5, maximum=math.inf)}, + ), + ( + {"name": "axis", "maximum": 0.5}, + {"axis": Range(minimum=-math.inf, maximum=0.5)}, + ), ( {"name": "axis", "minimum": 0.5, "maximum": None}, {"axis": Range(minimum=0.5, maximum=math.inf)},