Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.

Commit 6a3d678

Browse files
committed
Fix test for failed barcodes with pure_barcode=True
I reported this at rxing-core/rxing#58, and it is fixed as of rxing-cli 1.2.8
1 parent 2c880d4 commit 6a3d678

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

test/test_all.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
from itertools import product
44
from tempfile import mkdtemp
5+
from warnings import warn
56

67
from PIL import Image
78

@@ -55,18 +56,21 @@ def test_version():
5556
@with_setup(setup_reader)
5657
def _check_decoding(filename, expected_format, expected_raw, extra={}, as_Image=False, use_rxing=True):
5758
global test_zxing_reader, test_rxing_reader
59+
pure_barcode = True
5860
if not use_rxing and (3, 5, 0) <= test_zxing_reader.zxing_version_info < (3, 5, 3) and expected_format == 'PDF_417':
5961
# See https://github.com/zxing/zxing/issues/1682 and https://github.com/zxing/zxing/issues/1683
6062
raise unittest.SkipTest("ZXing v{} CommandLineRunner is broken for combination of {} barcode format and --raw option".format(
6163
test_zxing_reader.zxing_version, expected_format))
62-
elif use_rxing and not expected_raw:
63-
raise unittest.SkipTest("RXing-cli v{} is broken for failed barcodes with '--pure-barcode true'".format(
64+
elif use_rxing and test_rxing_reader.rxing_version_info <= (1, 2, 7) and not expected_raw:
65+
# See https://github.com/rxing-core/rxing/issues/58
66+
pure_barcode = False
67+
warn("RXing-cli v{} is broken for failed barcodes with '--pure-barcode true'".format(
6468
test_rxing_reader.rxing_version))
6569
path = os.path.join(test_barcode_dir, filename)
6670
what = Image.open(path) if as_Image else path
6771
logging.debug('Trying to parse {} with {}, expecting {!r}.'.format(path, ("RXing" if use_rxing else "ZXing"), expected_raw))
6872
reader = test_rxing_reader if use_rxing else test_zxing_reader
69-
dec = reader.decode(what, pure_barcode=True, **extra)
73+
dec = reader.decode(what, pure_barcode=pure_barcode, **extra)
7074
if expected_raw is None:
7175
assert dec.raw is None, (
7276
'Expected failure, but got result in {} format'.format(dec.format))

0 commit comments

Comments
 (0)