fonttools / fontbakery

🧁 A font quality assurance tool for everyone
https://fontbakery.readthedocs.io
Apache License 2.0
534 stars 99 forks source link

mock HTTP requests in the test suite #4621

Closed danc86 closed 1 month ago

danc86 commented 3 months ago

Description

I'm working on packaging fontbakery in nixpkgs, which requires that the test suite run without network access. I found a few tests which intentionally make network calls, but in most of them it seems desirable to mock out requests to live services. This will make them faster and more reproducible, and lets them run in an environment like nixpkgs where they are sandboxed from the network.

Checklist

danc86 commented 3 months ago

With these changes, the only remaining test case in the regression test suite which makes a network request is test_check_cjk_vertical_metrics_regressions().

If you like this approach of using requests-mock, I could refactor the remote_styles condition to also use requests to download the fonts zip file, and then update test_check_cjk_vertical_metrics_regressions() to return a mock zip file in the tests.

That would allow the complete test suite to run without making any network requests.

felipesanches commented 1 month ago

Hey, @danc86, it took me a long time to do it, but here it is: reviewed and merged! ;-)