[gnome-settings-daemon/benzea/ci-fixes: 7/19] tests: Use addClassCleanup in GsdTestCase
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/benzea/ci-fixes: 7/19] tests: Use addClassCleanup in GsdTestCase
- Date: Thu, 22 Jul 2021 12:27:12 +0000 (UTC)
commit e57551547eadf938e2180377acaf6aba9e2d0585
Author: Benjamin Berg <bberg redhat com>
Date: Mon Jul 19 21:13:03 2021 +0200
tests: Use addClassCleanup in GsdTestCase
tests/gsdtestcase.py | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/tests/gsdtestcase.py b/tests/gsdtestcase.py
index cf716b39..9926b3b3 100644
--- a/tests/gsdtestcase.py
+++ b/tests/gsdtestcase.py
@@ -62,6 +62,7 @@ class GSDTestCase(X11SessionTestCase):
# we do some string checks, disable translations
os.environ['LC_MESSAGES'] = 'C'
klass.workdir = tempfile.mkdtemp(prefix='gsd-plugin-test')
+ klass.addClassCleanup(shutil.rmtree, klass.workdir)
# Prevent applications from accessing an outside session manager
os.environ['SESSION_MANAGER'] = ''
@@ -93,20 +94,14 @@ class GSDTestCase(X11SessionTestCase):
klass.p_notify = klass.spawn_server_template(
'notification_daemon', {}, stdout=subprocess.PIPE)[0]
set_nonblock(klass.p_notify.stdout)
+ klass.addClassCleanup(lambda : (klass.p_notify.terminate(), klass.p_notify.wait()))
klass.start_session()
klass.start_monitor()
+ klass.addClassCleanup(klass.stop_monitor)
klass.settings_session = Gio.Settings(schema_id='org.gnome.desktop.session')
- @classmethod
- def tearDownClass(klass):
- klass.p_notify.terminate()
- klass.p_notify.wait()
- klass.stop_monitor()
- X11SessionTestCase.tearDownClass()
- shutil.rmtree(klass.workdir)
-
def run(self, result=None):
'''Show log files on failed tests
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]