From bd2d3103d6df33502a218e71461d1c7aa681e12a Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Tue, 5 Sep 2023 10:14:04 +0200 Subject: [PATCH] Test code for copy --- test-py/test_backend_copy.py | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test-py/test_backend_copy.py diff --git a/test-py/test_backend_copy.py b/test-py/test_backend_copy.py new file mode 100644 index 000000000..e8c45e0f7 --- /dev/null +++ b/test-py/test_backend_copy.py @@ -0,0 +1,42 @@ +import pathlib +import subprocess + +from test_backend_designspace import fileNamesFromDir + +from fontra.backends import getFileSystemBackend, newFileSystemBackend +from fontra.backends.copy import copyFont + +mutatorDSPath = ( + pathlib.Path(__file__).resolve().parent + / "data" + / "mutatorsans" + / "MutatorSans.designspace" +) + + +async def test_copyFont(tmpdir): + tmpdir = pathlib.Path(tmpdir) + destPath = tmpdir / "MutatorCopy.designspace" + sourceFont = getFileSystemBackend(mutatorDSPath) + destFont = newFileSystemBackend(destPath) + await copyFont(sourceFont, destFont) + assert [ + "MutatorCopy.designspace", + "MutatorCopy_BoldCondensed.ufo", + "MutatorCopy_BoldWide.ufo", + "MutatorCopy_LightWide.ufo", + "MutatorCopy_Regular.ufo", + ] == fileNamesFromDir(tmpdir) + + +def test_fontra_copy(tmpdir): + tmpdir = pathlib.Path(tmpdir) + destPath = tmpdir / "MutatorCopy.designspace" + subprocess.run(["fontra-copy", mutatorDSPath, destPath]) + assert [ + "MutatorCopy.designspace", + "MutatorCopy_BoldCondensed.ufo", + "MutatorCopy_BoldWide.ufo", + "MutatorCopy_LightWide.ufo", + "MutatorCopy_Regular.ufo", + ] == fileNamesFromDir(tmpdir)