How to unit test a Python function that draws PDF graphics?

前端 未结 5 1872
悲&欢浪女
悲&欢浪女 2020-12-09 10:01

I\'m writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as

5条回答
  •  囚心锁ツ
    2020-12-09 10:22

    You could capture the PDF as a bitmap (or at least a losslessly-compressed) image, and then compare the image generated by each test with a reference image of what it's supposed to look like. Any differences would be flagged as an error for the test.

提交回复
热议问题