Skip to content

Commit

Permalink
test: Better organize TestLowLevelErrors unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
igo95862 committed Jun 12, 2022
1 parent 7b6a102 commit 382ed39
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/test_low_level_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ async def hello_world(self) -> str:


class TestLowLevelErrors(IsolatedDbusTestCase):
async def test_low_level_error(self) -> None:
async def asyncSetUp(self) -> None:
await super().asyncSetUp()

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

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

loop = get_running_loop()
Expand All @@ -68,11 +70,12 @@ def silence_exceptions(*args: Any, **kwrags: Any) -> None:

loop.set_exception_handler(silence_exceptions)

async def test_property_getter_error(self) -> None:
with self.assertRaises(DbusFailedError) as cm:
await wait_for(test_object_connection.test_str.get_async(),
await wait_for(self.test_object_connection.test_str.get_async(),
timeout=1)

should_be_dbus_failed = cm.exception
self.assertIs(should_be_dbus_failed.__class__, DbusFailedError)

await test_object_connection.hello_world()
await self.test_object_connection.hello_world()

0 comments on commit 382ed39

Please sign in to comment.