Skip to content

Commit

Permalink
#4523 more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Mar 3, 2025
1 parent cb4ade7 commit 7a12ea7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions tests/unittests/unit/client/mixins/clientmixintest_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def setUp(self):
self.mixin = None
self.packet_handlers = {}
self.exit_codes = []
self.legacy_alias = {}

def tearDown(self):
unittest.TestCase.tearDown(self)
Expand Down Expand Up @@ -72,6 +73,9 @@ def verify_packet(self, index: int, expected) -> None:
log.error("[%3i] %s", i, packet)
raise RuntimeError("invalid packet slice %s, expected %s" % (pslice, expected))

def add_legacy_alias(self, legacy_name: str, name: str) -> None:
self.legacy_alias[legacy_name] = name

def add_packet_handler(self, packet_type: str, handler: Callable, main_thread=False):
# log("add_packet_handler%s", (packet_type, handler, main_thread))
self.packet_handlers[packet_type] = handler
Expand Down Expand Up @@ -101,6 +105,7 @@ def _test_mixin_class(self, mclass, opts, caps=None, protocol_type="xpra"):
fake_protocol.set_compression_level = lambda _x: None
fake_protocol.TYPE = protocol_type
x._protocol = fake_protocol # pylint: disable=protected-access
x.add_legacy_alias = self.add_legacy_alias
x.add_packets = self.add_packets
x.add_packet_handler = self.add_packet_handler
x.init(opts)
Expand Down
6 changes: 3 additions & 3 deletions tests/unittests/unit/server/mixins/child_command_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _ChildCommandServer():
self.handle_packet(("start-command", "test", command, True))
time.sleep(1)
info = self.mixin.get_info(self.protocol)
commands = info.get("commands")
commands = info.get("command")
assert commands
proc_info = commands.get(0)
assert proc_info
Expand All @@ -82,7 +82,7 @@ def _ChildCommandServer():
self.handle_packet(("start-command", "sleep", "sleep 10", True))
time.sleep(1)
info = self.mixin.get_info(self.protocol)
commands = info.get("commands")
commands = info.get("command")
assert commands
proc_info = commands.get(1)
assert proc_info
Expand All @@ -96,7 +96,7 @@ def _ChildCommandServer():
time.sleep(1)
self.mixin.child_reaper.poll()
info = self.mixin.get_info(self.protocol)
commands = info.get("commands")
commands = info.get("command")
assert commands
proc_info = commands.get(1)
assert proc_info.get("dead") is True
Expand Down

0 comments on commit 7a12ea7

Please # to comment.