Skip to content

Commit 37324ae

Browse files
committed
test: use skip_if_platform_not_linux helper where possible
Rather than re-implementing these checks, we can use this test framework's helper (introduced in commit c934087, PR #24358) called in a test's `skip_test_if_missing_module` method instead.
1 parent 3e69125 commit 37324ae

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

test/functional/feature_bind_extra.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
that bind happens on the expected ports.
88
"""
99

10-
import sys
11-
1210
from test_framework.netutil import (
1311
addr_to_hex,
1412
get_bind_addrs,
1513
)
1614
from test_framework.test_framework import (
1715
BitcoinTestFramework,
18-
SkipTest,
1916
)
2017
from test_framework.util import (
2118
assert_equal,
@@ -32,12 +29,11 @@ def set_test_params(self):
3229
self.bind_to_localhost_only = False
3330
self.num_nodes = 2
3431

35-
def setup_network(self):
32+
def skip_test_if_missing_module(self):
3633
# Due to OS-specific network stats queries, we only run on Linux.
37-
self.log.info("Checking for Linux")
38-
if not sys.platform.startswith('linux'):
39-
raise SkipTest("This test can only be run on Linux.")
34+
self.skip_if_platform_not_linux()
4035

36+
def setup_network(self):
4137
loopback_ipv4 = addr_to_hex("127.0.0.1")
4238

4339
# Start custom ports by reusing unused p2p ports

test/functional/rpc_bind.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test running bitcoind with the -rpcbind and -rpcallowip options."""
66

7-
import sys
8-
97
from test_framework.netutil import all_interfaces, addr_to_hex, get_bind_addrs, test_ipv6_local
108
from test_framework.test_framework import BitcoinTestFramework, SkipTest
119
from test_framework.util import assert_equal, assert_raises_rpc_error, get_rpc_proxy, rpc_port, rpc_url
@@ -17,6 +15,10 @@ def set_test_params(self):
1715
self.num_nodes = 1
1816
self.supports_cli = False
1917

18+
def skip_test_if_missing_module(self):
19+
# due to OS-specific network stats queries, this test works only on Linux
20+
self.skip_if_platform_not_linux()
21+
2022
def setup_network(self):
2123
self.add_nodes(self.num_nodes, None)
2224

@@ -61,14 +63,9 @@ def run_allowip_test(self, allow_ips, rpchost, rpcport):
6163
self.stop_nodes()
6264

6365
def run_test(self):
64-
# due to OS-specific network stats queries, this test works only on Linux
6566
if sum([self.options.run_ipv4, self.options.run_ipv6, self.options.run_nonloopback]) > 1:
6667
raise AssertionError("Only one of --ipv4, --ipv6 and --nonloopback can be set")
6768

68-
self.log.info("Check for linux")
69-
if not sys.platform.startswith('linux'):
70-
raise SkipTest("This test can only be run on linux.")
71-
7269
self.log.info("Check for ipv6")
7370
have_ipv6 = test_ipv6_local()
7471
if not have_ipv6 and not (self.options.run_ipv4 or self.options.run_nonloopback):

0 commit comments

Comments
 (0)