Skip to content

Commit c694dc5

Browse files
committed
Add test case for file:// path with non-empty netloc
1 parent ae1d4b6 commit c694dc5

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

test/test_all.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
from itertools import product
34
from tempfile import mkdtemp
45

56
from PIL import Image
@@ -99,10 +100,10 @@ def test_decoding_multiple():
99100
'{}: Expected {!r} but got {!r}'.format(filename, expected_format, dec.format))
100101

101102

102-
@params(False, True)
103-
def test_parsing(with_raw_bits):
103+
@params(*product((False, True), repeat=2))
104+
def test_parsing(with_raw_bits, with_netloc):
104105
stdout = ("""
105-
file:///tmp/default%20file.png (format: FAKE_DATA, type: TEXT):
106+
file://""") + ("NETWORK_SHARE" if with_netloc else "") + ("""/tmp/default%20file.png (format: FAKE_DATA, type: TEXT):
106107
Raw result:
107108
Élan|\tthe barcode is taking off
108109
Parsed result:
@@ -117,8 +118,8 @@ def test_parsing(with_raw_bits):
117118
Point 3: (205.23952,21.0)
118119
""")
119120
dec = zxing.BarCode.parse(stdout.encode())
120-
assert dec.uri == 'file:///tmp/default%20file.png'
121-
assert dec.path == '/tmp/default file.png'
121+
assert dec.uri == 'file://' + ("NETWORK_SHARE" if with_netloc else "") + '/tmp/default%20file.png'
122+
assert dec.path == (None if with_netloc else '/tmp/default file.png')
122123
assert dec.format == 'FAKE_DATA'
123124
assert dec.type == 'TEXT'
124125
assert dec.raw == 'Élan|\tthe barcode is taking off'

0 commit comments

Comments
 (0)