Files
unshackle/tests/core/test_qr_text.py
T

17 lines
670 B
Python

import segno
from unshackle.core.console import qr_text
TOP = {"\u2588": True, "\u2580": True, "\u2584": False, " ": False}
BOTTOM = {"\u2588": True, "\u2580": False, "\u2584": True, " ": False}
def test_each_line_holds_two_module_rows_of_the_code() -> None:
data = "https://login.example/scan?code=EXAMPLE"
rows = [[bool(v) for v in row] for row in segno.make_qr(data).matrix_iter(border=2)]
unpacked = []
for line in qr_text(data, indent=0).plain.splitlines():
unpacked += [[TOP[c] for c in line], [BOTTOM[c] for c in line]]
assert unpacked[: len(rows)] == rows
assert not any(cell for row in unpacked[len(rows) :] for cell in row)