forked from lincolnloop/python-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 23
/
test.py
36 lines (25 loc) · 1.12 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
from qrcode import QRCode as MacroQRCode
from uQR import QRCode as MicroQRCode
class TestMatrixCreation(unittest.TestCase):
def test_qr_library_equivalence(self):
"""
The `get_matrix` method of the uQR library should produce
identical output to that of the QRCode library.
"""
macro_qr = MacroQRCode()
macro_qr.add_data('uQR rocks!')
macro_matrix = macro_qr.get_matrix()
micro_qr = MicroQRCode()
micro_qr.add_data('uQR rocks!')
micro_matrix = micro_qr.get_matrix()
# The generated matrix should actually contains rows.
self.assertGreater(len(micro_matrix), 0)
# The uQR matrix should have the same number of rows as the
# QRCode matrix
self.assertEqual(len(micro_matrix), len(macro_matrix))
for micro_row, macro_row in zip(micro_matrix, macro_matrix):
# The row should actually contain data.
self.assertGreater(len(micro_row), 0)
# The two rows from the two libraries should be identical
self.assertEqual(len(micro_row), len(macro_row))