blueman
blueman copied to clipboard
Import tests are ran twice, and the run in test/test_imports.py ignores expected exceptions
blueman: 2.3
In the test suite, imports seem to be done by two tests:
- the one in
test/test_imports.py - individual submodule tests in subddirectories (
plugins/test_imports.py,plugins/applets/test_imports.py, etc.)
The individual submodule tests for plugin applets also have some expected exceptions - ones that are ignored (like missing hardware rfkill). The test in test/test_imports.py doesn't respect those exceptions.
This broke tests when upgrading the blueman package to 2.3 on Alpine Linux - see logs. (Not sure why this didn't appear earlier, since the code hasn't changed in the recent releases, although I seem to remember something similar happening at some point...). We can't do touch /dev/rfkill in the check script like the CI here, so the only option is to patch the tests manually.
Relevant chunk of the log:
======================================================================
ERROR: test_blueman_plugins_applet_KillSwitch_import (test.test_imports.TestImports)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/builds/knuxify/aports/community/blueman/src/blueman-2.3/test/test_imports.py", line 15, in <lambda>
setattr(self, name, lambda: __import__(mod_name))
File "/builds/knuxify/aports/community/blueman/src/blueman-2.3/blueman/plugins/applet/KillSwitch.py", line 24, in <module>
raise ImportError('Hardware kill switch not found')
ImportError: Hardware kill switch not found
======================================================================
ERROR: test_blueman_plugins_mechanism_RfKill_import (test.test_imports.TestImports)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/builds/knuxify/aports/community/blueman/src/blueman-2.3/test/test_imports.py", line 15, in <lambda>
setattr(self, name, lambda: __import__(mod_name))
File "/builds/knuxify/aports/community/blueman/src/blueman-2.3/blueman/plugins/mechanism/RfKill.py", line 4, in <module>
from blueman.plugins.applet.KillSwitch import RFKILL_TYPE_BLUETOOTH, RFKILL_OP_CHANGE_ALL
File "/builds/knuxify/aports/community/blueman/src/blueman-2.3/blueman/plugins/applet/KillSwitch.py", line 24, in <module>
raise ImportError('Hardware kill switch not found')
ImportError: Hardware kill switch not found
----------------------------------------------------------------------
I can think of two solutions to this:
- remove subdirectories, only run the main
test/test_imports.pytests, and move the expected exceptions there - remove
test/test_imports.pyand only use the tests in the subdirectories
The main issue with the latter is that it skips some tests. Here's a diff I ran between the packages imported by test/test_imports.py:
--- test1-sort (imported by test/test_imports.py)
+++ test2-sort (imported by test_imports.py in subdirs)
-blueman.Constants
-blueman.DeviceClass
-blueman.Functions
-blueman.Sdp
-blueman.Service
-blueman.bluemantyping
-blueman.bluez
-blueman.config
-blueman.config.AutoConnectConfig
-blueman.gobject
-blueman.gui
-blueman.main
-blueman.main.indicators.IndicatorInterface
-blueman.main.indicators.StatusNotifierItem
-blueman.plugins
-blueman.services
+_blueman
I'm willing to submit a patch to fix this, just let me know which approach is preferable, if any.
I don't see that anything changed there, either.
We could easily exclude the blueman.plugins.mechanism.RfKill and blueman.plugins.applet.KillSwitch modules from the generic import tests. However, I think the idea there is to provide a proper system so that plugins can get loaded properly and their files get evaluated completely.
Another solution could be to specify /dev/rfkill in some kind of property and use @patch on the test to switch it to something like /tmp/rfkill and set that file up.
I'm curious: Why can't you provide an arbitrary /dev/rfkill?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.