def test_pass_event_node(self): # same as above, but passes the event node into hid-decode source = self.uhid_device.device_nodes[0] with tempfile.NamedTemporaryFile(mode='r', delete=True) as outfile: decode(['hid-decode.test'] + self.cli_args + ['--output'.format(**locals()), outfile.name, source]) lines = outfile.readlines() self.assertEqual(self.rdesc, self.output_to_bytes(lines))
def test_pass_hidraw(self): # same as above, but passes the hidraw node into hid-decode source = self.uhid_device.hidraw_nodes[0] with tempfile.NamedTemporaryFile(mode='r', delete=True) as outfile: decode(['hid-decode.test'] + self.cli_args + [f'--output', outfile.name, source]) lines = outfile.readlines() self.assertEqual(self.rdesc, self.output_to_bytes(lines))
def run_hid_decode(self): with tempfile.NamedTemporaryFile(delete=True) as sourcefile: if isinstance(self.data, str): data = bytes(self.data, encoding='utf-8') else: data = self.data sourcefile.write(data) sourcefile.seek(0) with tempfile.NamedTemporaryFile(mode='r', delete=True) as outfile: decode(['hid-decode.test'] + self.cli_args + ['--output'.format(**locals()), outfile.name, sourcefile.name]) return outfile.readlines()