Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_convert_to_boolean_false():
qr = encoder.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
error='m', mask=4, boost_error=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version):
res.append(bytearray([not int(v >> 8 == 0) for v in row]))
expected = read_matrix('iso-fig-29')
assert expected == res
def test_finder_pattern_dark_light_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_FINDER_PATTERN_LIGHT] for v in row]))
expected = read_matrix('v1-finder-light')
assert expected == res
def test_issue_4_explicit_error():
qr = encoder.encode(1, error=None)
assert consts.VERSION_M1 == qr.version
assert qr.error is None
def test_timing_dark_and_light_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v in (consts.TYPE_TIMING_DARK, consts.TYPE_TIMING_LIGHT)] for v in row]))
expected = read_matrix('m2-timing-dark-and-light')
assert expected == res
def test_convert_to_boolean():
qr = encoder.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
error='m', mask=4, boost_error=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version):
res.append(bytearray([bool(v >> 8) for v in row]))
expected = read_matrix('iso-fig-29')
assert expected == res
def test_no_darkmodule_mqr():
# Micro QR Codes don't have a dark module.
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.extend([v == consts.TYPE_DARKMODULE for v in row])
assert True not in res
def test_format_light_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_FORMAT_LIGHT] for v in row]))
expected = read_matrix('v1-format-light')
assert expected == res
def test_finder_pattern_dark_and_light_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v in (consts.TYPE_FINDER_PATTERN_DARK, consts.TYPE_FINDER_PATTERN_LIGHT)] for v in row]))
expected = read_matrix('v1-finder-dark-and-light')
assert expected == res