improved get_devices test

This commit is contained in:
sezanzeb 2020-11-16 16:30:27 +01:00
parent 09cec4cfac
commit 121f6900d8
2 changed files with 7 additions and 5 deletions

View File

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

View File

@ -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',