@@ -43,6 +43,9 @@ class IndependentError(Exception):
4343 ...
4444
4545
46+ GOOD_STR = 'Good'
47+
48+
4649class InterfaceWithErrors (
4750 DbusInterfaceCommonAsync ,
4851 interface_name = 'org.example.test' ,
@@ -63,6 +66,22 @@ async def hello_error(self) -> str:
6366 async def hello_world (self ) -> str :
6467 return HELLO_WORLD
6568
69+ @dbus_property_async ('s' )
70+ def indep_err_setable (self ) -> str :
71+ return GOOD_STR
72+
73+ @indep_err_setable .setter
74+ def indep_err_setter (self , new_value : str ) -> None :
75+ raise IndependentError
76+
77+ @dbus_property_async ('s' )
78+ def derrive_err_settable (self ) -> str :
79+ return GOOD_STR
80+
81+ @derrive_err_settable .setter
82+ def derrive_err_setter (self , new_value : str ) -> None :
83+ raise DbusDerivePropertydError
84+
6685
6786class TestLowLevelErrors (IsolatedDbusTestCase ):
6887 async def asyncSetUp (self ) -> None :
@@ -100,3 +119,46 @@ async def test_property_getter_derived_error(self) -> None:
100119 self .test_object_connection .derrive_err_getter .get_async (),
101120 timeout = 1 ,
102121 )
122+
123+ await self .test_object_connection .hello_world ()
124+
125+ async def test_property_setter_independent_error (self ) -> None :
126+
127+ self .assertEqual (
128+ await wait_for (
129+ self .test_object_connection .indep_err_setable .get_async (),
130+ timeout = 1 ,
131+ ),
132+ GOOD_STR ,
133+ )
134+
135+ with self .assertRaises (DbusFailedError ) as cm :
136+ await wait_for (
137+ self .test_object_connection .
138+ indep_err_setable .set_async ('Test' ),
139+ timeout = 1 ,
140+ )
141+
142+ should_be_dbus_failed = cm .exception
143+ self .assertIs (should_be_dbus_failed .__class__ , DbusFailedError )
144+
145+ await self .test_object_connection .hello_world ()
146+
147+ async def test_property_setter_derived_error (self ) -> None :
148+
149+ self .assertEqual (
150+ await wait_for (
151+ self .test_object_connection .derrive_err_settable .get_async (),
152+ timeout = 1 ,
153+ ),
154+ GOOD_STR ,
155+ )
156+
157+ with self .assertRaises (DbusDerivePropertydError ):
158+ await wait_for (
159+ self .test_object_connection .
160+ derrive_err_settable .set_async ('Test' ),
161+ timeout = 1 ,
162+ )
163+
164+ await self .test_object_connection .hello_world ()
0 commit comments