Skip to content

Commit

Permalink
Added leak tests for low level error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
igo95862 committed Jun 12, 2022
1 parent ecc1efe commit 20b25d3
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion test/leak_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@
)
from os import environ
from resource import RUSAGE_SELF, getrusage
from typing import List, cast
from typing import Any, List, cast
from unittest import SkipTest

from sdbus.unittest import IsolatedDbusTestCase

from sdbus import DbusFailedError, request_default_bus_name_async

from .test_low_level_errors import (
DbusDerivePropertydError,
InterfaceWithErrors,
)
from .test_read_write_dbus_types import TestDbusTypes
from .test_sd_bus_async import TestPing, TestProxy, initialize_object

Expand Down Expand Up @@ -119,6 +125,38 @@ async def test_objects(self) -> None:

self.check_memory()

async def test_low_level_errors(self) -> None:
leak_test_enabled()

await request_default_bus_name_async('org.test')
self.test_object = InterfaceWithErrors()
self.test_object.export_to_dbus('/')

self.test_object_connection = InterfaceWithErrors.new_proxy(
'org.test', '/')

loop = get_running_loop()

def silence_exceptions(*args: Any, **kwrags: Any) -> None:
...

loop.set_exception_handler(silence_exceptions)

for _ in range(150_000):
with self.assertRaises(DbusFailedError):
await wait_for(
self.test_object_connection.indep_err_getter.get_async(),
timeout=1,
)

with self.assertRaises(DbusDerivePropertydError):
await wait_for(
self.test_object_connection.derrive_err_getter.get_async(),
timeout=1,
)

self.check_memory()

async def test_single_object(self) -> None:
leak_test_enabled()
await self.bus.request_name_async("org.example.test", 0)
Expand Down

0 comments on commit 20b25d3

Please sign in to comment.