"""Shared test fakes.""" import argparse class FakePrinter: """Records escpos calls instead of talking to hardware.""" def __init__(self): self.calls = [] def textln(self, text=""): self.calls.append(("textln", text)) def image(self, img, **kwargs): self.calls.append(("image", img)) def qr(self, content, **kwargs): self.calls.append(("qr", content)) def cut(self): self.calls.append(("cut", None)) def close(self): self.calls.append(("close", None)) def make_args(**overrides): defaults = { "usb": True, # avoids the network setup script in tests "ip": "192.168.192.168", "port": 9100, "timestamp": False, "message": None, "name": None, } defaults.update(overrides) return argparse.Namespace(**defaults)