class DeviceManagerTest(TestCase): def setUp(self): self.device = Device(name="AT Translated Set 2 keyboard") def test_nonexistant(self): self.assertRaises(DeviceError, Device, None, "Nonexistent") self.assertRaises(DeviceError, Device, 22) self.device.xid = "Dummy" self.assertRaises(CalledProcessError, self.device.set_state, 0) def test_set_state(self): self.device.set_state(0) self.assertEqual(self.device.get_state(), 0) self.device.set_state(1) self.assertEqual(self.device.get_state(), 1) def test_from_xid(self): d = Device(name="AT Translated Set 2 keyboard") d1 = Device(xid=d.xid) self.assertEqual(d.path, d1.path) def test_from_path(self): d = Device(xid=10) d1 = Device(path=d.path) self.assertEqual(d.xid, d1.xid)
def setUp(self): self.device = Device(name="AT Translated Set 2 keyboard")
context.signal_map = { SIGTERM: lambda s,f: Processor.instance().exit(), #SIGHUP: lambda s,f: Processor.instance().exit() } config_path = path.abspath(args.config) with context: p = Processor(config_path) if args.interactive: print "Available devices:" for name, xid in input_devices(): print " %s: %s" % (xid, name) print "Select device:" id = raw_input(">>") try: xid = int(id) except ValueError, IndexError: exit(0) device = Device(xid=xid) try: device.set_state(0) print "Now press some buttons or any key on main keyboard to exit" listen_device(device.listener) finally: device.set_state(1) else: parser.print_help()