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
def test_illegal_version(): with pytest.raises(pyqrcode.VersionError): builder.QRCodeBuilder('123', version=41, mode='numeric', error='M')
def test_illegal_error(): with pytest.raises(pyqrcode.ErrorLevelError): builder.QRCodeBuilder('123', version=40, mode='numeric', error='R')
def test_illegal_mode(): with pytest.raises(pyqrcode.ModeError): builder.QRCodeBuilder('test', 1, mode='murks', error='M')
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)
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)