From 40e055b7c8f85ba3429cf8899a0d80509e4afdf9 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 24 Jun 2022 13:32:52 +0200 Subject: [PATCH] tests: Fix error running tests with Python 3.11 In https://github.com/python/cpython/commit/664448d81f41c5fa971d8523a71b0f19e76cc136 the "errors" attribute was removed from the _Outcome object. Adapt the code to print the daemon log after a failed run(). --- tests/integration-test.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/integration-test.py b/tests/integration-test.py index 8504626..bcf525d 100755 --- a/tests/integration-test.py +++ b/tests/integration-test.py @@ -111,6 +111,14 @@ class Tests(dbusmock.DBusTestCase): self.log = None self.daemon = None + def run(self, result=None): + super(Tests, self).run(result) + if result and len(result.errors) + len(result.failures) > 0 and self.log: + with open(self.log.name) as f: + sys.stderr.write('\n-------------- daemon log: ----------------\n') + sys.stderr.write(f.read()) + sys.stderr.write('------------------------------\n') + def tearDown(self): del self.testbed self.stop_daemon() @@ -123,14 +131,6 @@ class Tests(dbusmock.DBusTestCase): self.polkitd.wait() self.polkitd = None - # on failures, print daemon log - errors = [x[1] for x in self._outcome.errors if x[1]] - if errors and self.log: - with open(self.log.name) as f: - sys.stderr.write('\n-------------- daemon log: ----------------\n') - sys.stderr.write(f.read()) - sys.stderr.write('------------------------------\n') - # # Daemon control and D-BUS I/O #