def test_saveImage_multipage(tmpdir): tmpdir = pathlib.Path(tmpdir) db = Drawing() namespace = makeDrawbotNamespace(db) runScriptSource(multipageSource, "<string>", namespace) assert [] == sorted(tmpdir.glob("*.png")) outputPath = tmpdir / "test.png" db.saveImage(outputPath) expected_filenames = ['test_0.png', 'test_1.png', 'test_2.png'] assert expected_filenames == [p.name for p in sorted(tmpdir.glob("*.png"))]
def test_saveImage_multipage(tmpdir, script, imageType, expectedFilenames): glob_pattern = f"*.{imageType}" tmpdir = pathlib.Path(tmpdir) db = Drawing() namespace = makeDrawbotNamespace(db) runScriptSource(script, "<string>", namespace) assert [] == sorted(tmpdir.glob(glob_pattern)) outputPath = tmpdir / f"test.{imageType}" db.saveImage(outputPath) assert expectedFilenames == [p.name for p in sorted(tmpdir.glob(glob_pattern))]
def test_apitest(apiTestPath): db = Drawing() namespace = makeDrawbotNamespace(db) runScript(apiTestPath, namespace) if not apiTestsOutputDir.exists(): apiTestsOutputDir.mkdir() outputPath = apiTestsOutputDir / (apiTestPath.stem + ".png") expectedOutputPath = apiTestsExpectedOutputDir / (apiTestPath.stem + ".png") db.saveImage(outputPath) same, reason = compareImages(outputPath, expectedOutputPath) assert same, reason
def test_saveImage_mp4_codec(tmpdir): from drawbot_skia import ffmpeg ffmpeg.FFMPEG_PATH = ffmpeg.getPyFFmpegPath() # Force ffmpeg from pyffmpeg tmpdir = pathlib.Path(tmpdir) db = Drawing() namespace = makeDrawbotNamespace(db) runScriptSource(multipageSource, "<string>", namespace) assert [] == sorted(tmpdir.glob("*.png")) db.saveImage(tmpdir / "test.mp4") db.saveImage(tmpdir / "test2.mp4", codec="mpeg4") expectedFilenames = ['test.mp4', 'test2.mp4'] paths = sorted(tmpdir.glob("*.mp4")) assert paths[0].stat().st_size < paths[1].stat().st_size assert expectedFilenames == [p.name for p in paths]
def test_apitest(apiTestPath, imageType): apiTestPath = pathlib.Path(apiTestPath) db = Drawing() namespace = makeDrawbotNamespace(db) runScript(apiTestPath, namespace) if not apiTestsOutputDir.exists(): apiTestsOutputDir.mkdir() fileName = (apiTestPath.stem + f".{imageType}") outputPath = apiTestsOutputDir / fileName expectedOutputPath = apiTestsExpectedOutputDir / fileName db.saveImage(outputPath) if (apiTestPath.stem, imageType, sys.platform) in expectedFailures: # Skip late, so we can still inspect the output pytest.skip(f"Skipping expected failure {apiTestPath.stem}.{imageType}") same, reason = compareImages(outputPath, expectedOutputPath) assert same, f"{reason} {apiTestPath.name} {imageType}"