From 5f23cb2594e7b026f7674c0955c12b91a7ebdf0f Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Fri, 21 Jan 2022 19:01:31 +0000 Subject: [PATCH] Add test for renaming layers --- tests/test_ufoLib2.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_ufoLib2.py b/tests/test_ufoLib2.py index 3a53288a..478999b7 100644 --- a/tests/test_ufoLib2.py +++ b/tests/test_ufoLib2.py @@ -284,3 +284,17 @@ def test_convert_on_setattr( assert not isinstance(obj, attr_type) setattr(o, attr_name, obj) assert isinstance(getattr(o, attr_name), attr_type) + + +def test_LayerSet_rename_layer(tmp_path: Path, datadir: Path) -> None: + ufo = ufoLib2.Font.open(datadir / "MutatorSansBoldCondensed.ufo") + ufo_tmp_path = tmp_path / "test.ufo" + + # Make sure we are not in overwrite mode before renaming. + ufo.save(ufo_tmp_path) + ufo = ufoLib2.Font.open(ufo_tmp_path) + ufo.renameLayer("background", "public.background2") + ufo.save() + + ufo2 = ufoLib2.Font.open(ufo_tmp_path) + assert ufo == ufo2