Skip to content

Commit

Permalink
Mock jukebox.publishing in tests to avoid zmq
Browse files Browse the repository at this point in the history
Currently it is hard to install zmq (MiczFlor#2050) and for
CI pytest `zmq` is not available.
As the test do not really require `jukebox.publishing`
running, mocking it in the test avoids it being imported.

Thus the tests do not require `zmq` to be installed.
  • Loading branch information
pre-commit fix Vito Zanotelli committed Jan 19, 2024
1 parent 51d9915 commit a181f8c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/evdev/test_evdev_init.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
""" Tests for the evdev __init__ module
"""
import sys
import unittest
from unittest.mock import patch
from unittest.mock import MagicMock

# Before importing the module, the jukebox.plugs decorators need to be patched
# to not try to register the plugins
Expand All @@ -16,6 +18,10 @@ def dummy_decorator(fkt):
plugin.initialize = dummy_decorator
plugin.atexit = dummy_decorator

# Mock the jukebox.publishing module to prevent issues with zmq
# which is currently hard to install(see issue #2050)
# and not installed properly for CI
sys.modules['jukebox.publishing'] = MagicMock()

# Import uses the patched decorators
from components.controls.event_devices import _input_devices_to_key_mapping # noqa: E402
Expand Down

0 comments on commit a181f8c

Please sign in to comment.