From 75ae817eb235c028a2747a501342372a5c0302dc Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Thu, 18 Jun 2026 14:48:11 +0200 Subject: [PATCH] support/testing: test_nftables.py: use assertRunNotOk() Use the helper to simplify the test. Signed-off-by: Peter Korsgaard Acked-by: Fiona Klute Signed-off-by: Peter Korsgaard --- support/testing/tests/package/test_nftables.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/support/testing/tests/package/test_nftables.py b/support/testing/tests/package/test_nftables.py index 2622c7e822..62e14d5d35 100644 --- a/support/testing/tests/package/test_nftables.py +++ b/support/testing/tests/package/test_nftables.py @@ -69,8 +69,7 @@ class TestNftables(infra.basetest.BRTest): # A ping to 127.0.0.2 is expected to fail, because our rule is # supposed to drop it. ping_test_cmd = ping_cmd_prefix + "127.0.0.2" - _, exit_code = self.emulator.run(ping_test_cmd) - self.assertNotEqual(exit_code, 0) + self.assertRunNotOk(ping_test_cmd) # We completely delete the table. This should also delete the # chain and the rule. @@ -128,8 +127,7 @@ class TestNftablesInit(TestNftables): # should allow ping to 127.0.0.1, but not 127.0.0.2. ping_cmd_prefix = "ping -c 3 -i 0.5 -W 2 " self.assertRunOk(ping_cmd_prefix + "127.0.0.1") - _, exit_code = self.emulator.run(ping_cmd_prefix + "127.0.0.2") - self.assertNotEqual(exit_code, 0) + self.assertRunNotOk(ping_cmd_prefix + "127.0.0.2") # Stop should flush the rules, ping to both addresses should # work now. @@ -140,5 +138,4 @@ class TestNftablesInit(TestNftables): # Start is essentially the same as reload, check that # 127.0.0.2 gets blocked again. self.assertRunOk("/etc/init.d/S35nftables start") - _, exit_code = self.emulator.run(ping_cmd_prefix + "127.0.0.2") - self.assertNotEqual(exit_code, 0) + self.assertRunNotOk(ping_cmd_prefix + "127.0.0.2")