Skip to content

Commit

Permalink
don't you love it when things break overnight?
Browse files Browse the repository at this point in the history
  • Loading branch information
sezanzeb committed Oct 1, 2024
1 parent 88a13a9 commit ea52f85
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions tests/lib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def input_props(self):
uinputs = {}


class UInput:
class UInputMock:
def __init__(self, events=None, name="unnamed", *args, **kwargs):
self.fd = 0
self.write_count = 0
Expand Down Expand Up @@ -260,10 +260,10 @@ def copy(self):
return [
patch.object(evdev, "list_devices", list_devices),
patch.object(evdev, "InputDevice", InputDevice),
patch.object(evdev.UInput, "capabilities", UInput.capabilities),
patch.object(evdev.UInput, "write", UInput.write),
patch.object(evdev.UInput, "syn", UInput.syn),
patch.object(evdev.UInput, "__init__", UInput.__init__),
patch.object(evdev.UInput, "capabilities", UInputMock.capabilities),
patch.object(evdev.UInput, "write", UInputMock.write),
patch.object(evdev.UInput, "syn", UInputMock.syn),
patch.object(evdev.UInput, "__init__", UInputMock.__init__),
patch.object(evdev, "InputEvent", PatchedInputEvent),
]

Expand Down
12 changes: 9 additions & 3 deletions tests/new_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import os
import subprocess
import traceback
import tracemalloc

from tests.lib.cleanup import cleanup, quick_cleanup
Expand Down Expand Up @@ -91,16 +92,21 @@ def setUpClass():

create_fixture_pipes()

# I don't know. Somehow tearDownClass is called before the test, so lets
# make sure the patches are started already when the class is set up.
for patch in patches:
patch.start()

original_setUpClass()

def tearDownClass():
original_tearDownClass()

remove_fixture_pipes()

# Do the more thorough cleanup after all tests of classes, because it slows
# tests down. If this is required after each test, call it in your tearDown
# method.
# Do the more thorough cleanup only after all tests of classes, because it
# slows tests down. If this is required after each test, call it in your
# tearDown method.
cleanup()

def setUp(self):
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/test_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
from pydantic import ValidationError

from inputremapper.input_event import InputEvent
from tests.lib.global_uinputs import (
reset_global_uinputs_for_service,
reset_global_uinputs_for_gui,
)
from tests.lib.patches import uinputs
from tests.lib.cleanup import quick_cleanup
from tests.lib.constants import EVENT_READ_TIMEOUT
Expand Down

0 comments on commit ea52f85

Please sign in to comment.