From 121f6900d876a526d0ad9fcbb5113f81e2136600 Mon Sep 17 00:00:00 2001 From: sezanzeb Date: Mon, 16 Nov 2020 16:30:27 +0100 Subject: [PATCH] improved get_devices test --- keymapper/linux.py | 1 - tests/testcases/linux.py | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/keymapper/linux.py b/keymapper/linux.py index cef5efc4..69b4fb28 100644 --- a/keymapper/linux.py +++ b/keymapper/linux.py @@ -150,7 +150,6 @@ class GetDevicesProcess(multiprocessing.Process): } self.pipe.send(result) - return result def get_devices(): diff --git a/tests/testcases/linux.py b/tests/testcases/linux.py index 90a318be..cf07045f 100644 --- a/tests/testcases/linux.py +++ b/tests/testcases/linux.py @@ -27,13 +27,16 @@ from keymapper.linux import GetDevicesProcess class TestLinux(unittest.TestCase): def test_create_preset_1(self): class FakePipe: - def send(self, stuff): - pass + devices = None + + def send(self, devices): + self.devices = devices # don't actually start the process, just use the `run` function. # otherwise the coverage tool can't keep track. - devices = GetDevicesProcess(FakePipe()).run() - self.assertDictEqual(devices, { + pipe = FakePipe() + GetDevicesProcess(pipe).run() + self.assertDictEqual(pipe.devices, { 'device 1': { 'paths': [ '/dev/input/event11',