Пример #1
0
def test_qr_pdf(tmp_path, data):
    doc = qr.qr_pdf(data)
    out_fn = os.path.join(tmp_path, "out.pdf")
    doc.save(out_fn)

    matrix = fitz.Matrix(4, 4)
    data = doc[0].getPixmap(matrix=matrix).getImageData()
    im = Image.open(io.BytesIO(data))

    decode(im)[0].data == data
Пример #2
0
def test_read_json_qr(tmp_path, data):
    doc = qr.qr_pdf(json.dumps(data))
    read_json = qr.read_json_qr(doc[0])
    # assert isinstance(read_json, dict)
    assert read_json == data
Пример #3
0
def test_read_no_json_qr(tmp_path, data):
    doc = qr.qr_pdf(data)
    with pytest.raises(json.JSONDecodeError):
        read_json = qr.read_json_qr(doc[0])
Пример #4
0
def test_read_json_qr_robust_fail(tmp_path, data):
    doc = qr.qr_pdf(json.dumps(data))
    with pytest.raises(ValueError):
        read_json = qr.read_json_qr_robust(doc[0],
                                           relative_rect=(0, 0, .1, .1))