Skip to content

Commit 6f36af9

Browse files
committed
The ZXing v3.5.0+ --raw option is broken for PDF_417 barcodes
The combination of '--raw' with certain barcode types, including PDF_417, is broken: CommandLineRunner will fail with NullPointerException. See zxing/zxing#1682 for more details.
1 parent 69a84ec commit 6f36af9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/test_all.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from nose2.tools.decorators import with_setup
88
from nose2.tools.such import helper
9+
import unittest
910

1011
import zxing
1112

@@ -48,6 +49,10 @@ def test_version():
4849
@with_setup(setup_reader)
4950
def _check_decoding(filename, expected_format, expected_raw, extra={}, as_Image=False):
5051
global test_reader
52+
if test_reader.zxing_version_info >= (3, 5, 0) and expected_format == 'PDF_417':
53+
# See https://github.com/zxing/zxing/issues/1682 and https://github.com/zxing/zxing/issues/1683
54+
raise unittest.SkipTest("ZXing v{} CommandLineRunner is broken for combination of {} barcode format and --raw option".format(
55+
test_reader.zxing_version, expected_format))
5156
path = os.path.join(test_barcode_dir, filename)
5257
what = Image.open(path) if as_Image else path
5358
logging.debug('Trying to parse {}, expecting {!r}.'.format(path, expected_raw))
@@ -83,8 +88,10 @@ def test_possible_formats():
8388
@with_setup(setup_reader)
8489
def test_decoding_multiple():
8590
global test_reader
86-
filenames = [os.path.join(test_barcode_dir, filename) for filename, expected_format, expected_raw in test_valid_images]
87-
for dec, (filename, expected_format, expected_raw) in zip(test_reader.decode(filenames, pure_barcode=True), test_valid_images):
91+
# See https://github.com/zxing/zxing/issues/1682 and https://github.com/zxing/zxing/issues/1683
92+
_tvi = [x for x in test_valid_images if test_reader.zxing_version_info < (3, 5, 0) or x[1] != 'PDF_417']
93+
filenames = [os.path.join(test_barcode_dir, filename) for filename, expected_format, expected_raw in _tvi]
94+
for dec, (filename, expected_format, expected_raw) in zip(test_reader.decode(filenames, pure_barcode=True), _tvi):
8895
assert dec.raw == expected_raw, (
8996
'{}: Expected {!r} but got {!r}'.format(filename, expected_raw, dec.parsed))
9097
assert dec.format == expected_format, (

0 commit comments

Comments
 (0)