Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_printer():
return Dummy(magic_encode_args={'disabled': True, 'encoding': 'CP437'})
def test_size():
"""Test QR box size"""
instance = printer.Dummy()
instance.qr("1234", native=True, size=7)
expected = b'\x1d(k\x04\x001A2\x00\x1d(k\x03\x001C\x07\x1d(k\x03\x001E0\x1d' \
b'(k\x07\x001P01234\x1d(k\x03\x001Q0'
assert(instance.output == expected)
def test_function_panel_button_on():
"""test the panel button function (enabling) by comparing output"""
instance = printer.Dummy()
instance.panel_buttons()
assert(instance.output == b'\x1B\x63\x35\x00')
def test_line_spacing_code_gen():
printer = Dummy()
printer.line_spacing(10)
assert printer.output == b'\x1b3\n'
def test_code_check(bctype, data):
"""should raise an error if the barcode code is invalid.
"""
instance = printer.Dummy()
with pytest.raises(BarcodeCodeError):
instance.barcode(data, bctype)
assert instance.output == b''
def test_graphics_both():
"""
Test printing black/white graphics
"""
instance = printer.Dummy()
instance.image('test/resources/black_white.png', impl="graphics")
assert(instance.output == b'\x1d(L\x0c\x000p0\x01\x011\x02\x00\x02\x00\xc0\x00\x1d(L\x02\x0002')
def test_instantiation():
"""test the instantiation of a escpos-printer class and basic printing"""
instance = printer.Dummy()
instance.text('This is a test\n')
def main():
dummy = printer.Dummy()
dummy.hw('init')
for codepage in sys.argv[1:] or ['USA']:
dummy.set(height=2, width=2)
dummy._raw(codepage + "\n\n\n")
print_codepage(dummy, codepage)
dummy._raw("\n\n")
dummy.cut()
print(dummy.output)
mt.paste(st_7, (0, tts))
tts += st_7.size[1]
mt.paste(st_5, (0, tts))
tts += st_5.size[1]
mt.paste(st_6, (0, tts))
sffs = []
sfs = [
f'{uuid.uuid4()}'.replace('-', '') + '.jpg',
f'{uuid.uuid4()}'.replace('-', '') + '.txt'
]
for f in sfs:
sffs.append(path.join(getcwd(), f))
mt.save(sfs[0], format="JPEG")
p = Dummy()
p.image(sfs[0], fragment_height=tt, high_density_vertical=True)
p.cut()
f = open(sfs[1], 'wb+')
f.write(p.output)
p.close()
f.close()
text = f'print /D:\\\localhost\\"{pname}" "{sfs[1]}"'
system(text)
for f in sffs:
if path.isfile(f):
remove(f)