improved get_devices test

first
sezanzeb 4 years ago
parent 09cec4cfac
commit 121f6900d8

@ -150,7 +150,6 @@ class GetDevicesProcess(multiprocessing.Process):
} }
self.pipe.send(result) self.pipe.send(result)
return result
def get_devices(): def get_devices():

@ -27,13 +27,16 @@ from keymapper.linux import GetDevicesProcess
class TestLinux(unittest.TestCase): class TestLinux(unittest.TestCase):
def test_create_preset_1(self): def test_create_preset_1(self):
class FakePipe: class FakePipe:
def send(self, stuff): devices = None
pass
def send(self, devices):
self.devices = devices
# don't actually start the process, just use the `run` function. # don't actually start the process, just use the `run` function.
# otherwise the coverage tool can't keep track. # otherwise the coverage tool can't keep track.
devices = GetDevicesProcess(FakePipe()).run() pipe = FakePipe()
self.assertDictEqual(devices, { GetDevicesProcess(pipe).run()
self.assertDictEqual(pipe.devices, {
'device 1': { 'device 1': {
'paths': [ 'paths': [
'/dev/input/event11', '/dev/input/event11',

Loading…
Cancel
Save