tests: Fix subsequent tests after first power-profile test failure

If the first power-profile installed test fails (for example, because
xdg-desktop-portal isn’t available), correctly tear down the dbusmock
object, or it will cause setUp() to fail when the next test in the suite
is run.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2481
This commit is contained in:
Philip Withnall 2021-09-06 18:57:06 +01:00
parent d051ef1611
commit 4f62fdfd29

View File

@ -66,12 +66,16 @@ try:
try:
self.xdp = subprocess.Popen([XDG_DESKTOP_PORTAL_PATH])
except FileNotFoundError:
self.p_mock.terminate()
self.p_mock.wait()
raise unittest.SkipTest("xdg-desktop-portal not available")
try:
self.wait_for_bus_object('org.freedesktop.portal.Desktop',
'/org/freedesktop/portal/desktop')
except:
self.p_mock.terminate()
self.p_mock.wait()
raise
# subprocess.Popen(['gdbus', 'monitor', '--session', '--dest', 'org.freedesktop.portal.Desktop'])