From a4ef71a5927897c01326c1388f81f0c6c34b953b Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Thu, 18 Jun 2026 14:48:13 +0200 Subject: [PATCH] support/testing: test_polkit.py: use assertRun{, Not}Ok() Use the helpers to simplify the test. Signed-off-by: Peter Korsgaard --- support/testing/tests/package/test_polkit.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/support/testing/tests/package/test_polkit.py b/support/testing/tests/package/test_polkit.py index 3414fd5159..8ff02d91df 100644 --- a/support/testing/tests/package/test_polkit.py +++ b/support/testing/tests/package/test_polkit.py @@ -43,20 +43,16 @@ class TestPolkitSystemd(TestPolkitInfra): rule_file = "systemd-timesyncd-restart.rules" for rule_path in TestPolkitInfra.rule_paths: cmd = "su brtest -c '/bin/systemctl restart systemd-timesyncd.service'" - _, exit_code = self.emulator.run(cmd, 10) - self.assertNotEqual(exit_code, 0) + self.assertRunNotOk(cmd, 10) cmd = "cp /root/{file} {path}".format(file=rule_file, path=rule_path) - _, exit_code = self.emulator.run(cmd, 10) - self.assertEqual(exit_code, 0) + self.assertRunOk(cmd, 10) cmd = "su brtest -c '/bin/systemctl restart systemd-timesyncd.service'" - _, exit_code = self.emulator.run(cmd, 10) - self.assertEqual(exit_code, 0) + self.assertRunOk(cmd, 10) cmd = "rm {path}/{file}".format(file=rule_file, path=rule_path) - _, exit_code = self.emulator.run(cmd, 10) - self.assertEqual(exit_code, 0) + self.assertRunOk(cmd, 10) class TestPolkitInitd(TestPolkitInfra): @@ -73,8 +69,7 @@ class TestPolkitInitd(TestPolkitInfra): self.assertEqual(output[0], "Error executing command as another user: Not authorized") cmd = "cp /root/{file} {path}/{file}".format(file=rule_file, path=rule_path) - _, exit_code = self.emulator.run(cmd, 10) - self.assertEqual(exit_code, 0) + self.assertRunOk(cmd, 10) cmd = "su brtest -c 'pkexec hello-polkit'" output, exit_code = self.emulator.run(cmd, 10) @@ -82,5 +77,4 @@ class TestPolkitInitd(TestPolkitInfra): self.assertEqual(output[0], "Hello polkit!") cmd = "rm {path}/{file}".format(file=rule_file, path=rule_path) - _, exit_code = self.emulator.run(cmd, 10) - self.assertEqual(exit_code, 0) + self.assertRunOk(cmd, 10)