Esempio n. 1
0
 def __init__(self,
              content,
              error='H',
              version=None,
              mode=None,
              encoding=None):
     # Build the QR code
     self.builder = builder.QRCodeBuilder(content=content,
                                          version=version,
                                          mode=mode,
                                          error=error,
                                          encoding=encoding)
     self.code = self.builder.code
     self.data = self.builder.data
     self.encoding = self.builder.encoding
     self.version = self.builder.version
     self.mode = self.builder.mode
     self.error = self.builder.error
Esempio n. 2
0
def test_illegal_version():
    with pytest.raises(pyqrcode.VersionError):
        builder.QRCodeBuilder('123', version=41, mode='numeric', error='M')
Esempio n. 3
0
def test_illegal_error():
    with pytest.raises(pyqrcode.ErrorLevelError):
        builder.QRCodeBuilder('123', version=40, mode='numeric', error='R')
Esempio n. 4
0
def test_illegal_mode():
    with pytest.raises(pyqrcode.ModeError):
        builder.QRCodeBuilder('test', 1, mode='murks', error='M')
Esempio n. 5
0
def test_illegal_mode():
    try:
        builder.QRCodeBuilder('test', 1, mode='murks', error='M')
        raise Exception('Expected an error for illegal mode')
    except ValueError as ex:
        assert 'murks' in str(ex)
Esempio n. 6
0
def test_illegal_version():
    try:
        builder.QRCodeBuilder('123', version=41, mode='numeric', error='M')
        raise Exception('Expected an error for illegal mode')
    except ValueError as ex:
        assert '41' in str(ex)