From d92aec6520bc0d13cf5d0cde412c7aee0a3de3fb Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 11 Nov 2011 15:19:04 +0100 Subject: [PATCH] src/linux/integration-test: Port to Python 3 --- src/linux/integration-test | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/linux/integration-test b/src/linux/integration-test index 1d6a5b3..cc2b329 100755 --- a/src/linux/integration-test +++ b/src/linux/integration-test @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # upower integration test suite # @@ -47,10 +47,11 @@ class Tests(unittest.TestCase): else: print('Testing installed system binaries') daemon_path = None - for l in open('/usr/share/dbus-1/system-services/org.freedesktop.UPower.service'): - if l.startswith('Exec='): - daemon_path = l.split('=', 1)[1].strip() - break + with open('/usr/share/dbus-1/system-services/org.freedesktop.UPower.service') as f: + for line in f: + if line.startswith('Exec='): + daemon_path = line.split('=', 1)[1].strip() + break assert daemon_path, 'could not determine daemon path from D-BUS .service file' # if we are root, test the real thing on the system bus, otherwise @@ -87,7 +88,7 @@ class Tests(unittest.TestCase): shutil.rmtree(self.sysfs) # on failures, print daemon log - if not self._resultForDoCleanups.wasSuccessful(): + if not self._outcomeForDoCleanups.success: with open(self.log.name) as f: sys.stderr.write('\n-------------- daemon log: ----------------\n') sys.stderr.write(f.read()) @@ -216,7 +217,7 @@ class Tests(unittest.TestCase): self.start_daemon() self.assertEqual(self.proxy.EnumerateDevices(), []) - self.assertRegexpMatches(self.get_dbus_property('DaemonVersion'), '^[0-9.]+$') + self.assertRegex(self.get_dbus_property('DaemonVersion'), '^[0-9.]+$') # without any devices we should assume AC self.assertEqual(self.get_dbus_property('OnBattery'), False)