From eea73d465e5356e9b8d8f41c4a797b5a5aaa63af Mon Sep 17 00:00:00 2001 From: fanquake Date: Thu, 12 Jan 2023 13:26:05 +0000 Subject: [PATCH] test: skip sqlite3 tests if it isn't available Fixes #26819. Related too #26873. --- test/functional/test_framework/test_framework.py | 7 +++++++ test/functional/wallet_descriptor.py | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 863df00ba1..823958397d 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -854,6 +854,13 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): except ImportError: raise SkipTest("python3-zmq module not available.") + def skip_if_no_py_sqlite3(self): + """Attempt to import the sqlite3 package and skip the test if the import fails.""" + try: + import sqlite3 # noqa + except ImportError: + raise SkipTest("sqlite3 module not available.") + def skip_if_no_python_bcc(self): """Attempt to import the bcc package and skip the tests if the import fails.""" try: diff --git a/test/functional/wallet_descriptor.py b/test/functional/wallet_descriptor.py index 2b70e5ecc9..f7fb38482a 100755 --- a/test/functional/wallet_descriptor.py +++ b/test/functional/wallet_descriptor.py @@ -4,7 +4,11 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test descriptor wallet function.""" import os -import sqlite3 + +try: + import sqlite3 +except ImportError: + pass from test_framework.blocktools import COINBASE_MATURITY from test_framework.test_framework import BitcoinTestFramework @@ -27,6 +31,7 @@ class WalletDescriptorTest(BitcoinTestFramework): def skip_test_if_missing_module(self): self.skip_if_no_wallet() self.skip_if_no_sqlite() + self.skip_if_no_py_sqlite3() def run_test(self): if self.is_bdb_compiled():