Add test with pyzbar, to use external library to validate rendered barcodes#256
Add test with pyzbar, to use external library to validate rendered barcodes#256rejjen wants to merge 3 commits intoWhyNotHugo:mainfrom
Conversation
WhyNotHugo
left a comment
There was a problem hiding this comment.
Are the changes to barcode/isxn.py related?
| try: | ||
| import cairosvg | ||
| import cairocffi | ||
| cairocffi.Context(cairocffi.ImageSurface(cairocffi.FORMAT_ARGB32, 1, 1)) | ||
| HAS_CAIROSVG = True | ||
| except (ImportError, OSError): | ||
| HAS_CAIROSVG = False |
There was a problem hiding this comment.
I'd prefer for tests to outright fail; this skips them silently and it would be easy to miss that they're not running properly.
I have no objection to adding test-only dependencies; users won't be affected by these.
There was a problem hiding this comment.
It should mark tests as skipped I believe and provide reason if library is not loaded correctly.
https://github.com/WhyNotHugo/python-barcode/pull/256/changes#diff-2d1975a58b23083a3f9f1331cb6534c4e8da053b6f66b1c60a1c035ec035d79bR99
Similarly to pytest.importorskip above.
pyproject.toml
Outdated
|
|
||
| [project.optional-dependencies] | ||
| images = ["pillow"] | ||
| test_with_pyzbar = ["pillow", "cairosvg", "pyzbar"] |
There was a problem hiding this comment.
Let's use dependency groups for these:
[dependency-groups]
test = ["pillow", "cairosvg", "pyzbar"]
``
Yes, without changes validation will fail for tests/test_with_pyzbar.py::test_imagewriter - AssertionError: ISSN failed to decode. There is some overlap with PR #255 |
This is attempt to handle #181.
Requires Pillow and pyzbar to do any testing, but should gracefully skip if not installed
Requires cairosvg to test svg rendered, but also gracefully skip.
They should install with
pip install .[test_with_pyzbar]