aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorlaanwj <126646+laanwj@users.noreply.github.com>2022-05-04 19:52:09 +0200
committerlaanwj <126646+laanwj@users.noreply.github.com>2022-05-04 19:52:16 +0200
commit0047d9b89b9fa6be660c363961cf0af72fa62ecf (patch)
treeed887b5f7e593cbf405f9feff3d3755b1e96bda2 /test/functional
parentbde5836f99966b382463a585db87faae27514a70 (diff)
parent027aab663aaca32818051d456c3900326377281c (diff)
downloadbitcoin-0047d9b89b9fa6be660c363961cf0af72fa62ecf.tar.xz
Merge bitcoin/bitcoin#24993: test, contrib, refactor: use `with` when opening a file
027aab663aaca32818051d456c3900326377281c test, contrib, refactor: use `with` when opening a file (brunoerg) Pull request description: When manipulating a file in Python without using `with()`, you have to close the file manually, so this PR does it in `get_block_hashes` (`contrib/linearize/linearize-data.py`). Edit: this PR does it for all occurances that previously weren't using `with`. ACKs for top commit: laanwj: Code review ACK 027aab663aaca32818051d456c3900326377281c Tree-SHA512: 879400968e0013e8678ec16f1fe5d0963a73c1e0d442ca34802d885214f0783d2e9a9b500fc6be7c3b93560a367b6a3d685eee24d2f9ce53fddf064ea6feecf8
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/feature_config_args.py3
-rwxr-xr-xtest/functional/feature_versionbits_warning.py3
2 files changed, 4 insertions, 2 deletions
diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py
index eea5fa24ee..fe3196d5ee 100755
--- a/test/functional/feature_config_args.py
+++ b/test/functional/feature_config_args.py
@@ -247,7 +247,8 @@ class ConfArgsTest(BitcoinTestFramework):
conf_file = os.path.join(default_data_dir, "bitcoin.conf")
# datadir needs to be set before [chain] section
- conf_file_contents = open(conf_file, encoding='utf8').read()
+ with open(conf_file, encoding='utf8') as f:
+ conf_file_contents = f.read()
with open(conf_file, 'w', encoding='utf8') as f:
f.write(f"datadir={new_data_dir}\n")
f.write(conf_file_contents)
diff --git a/test/functional/feature_versionbits_warning.py b/test/functional/feature_versionbits_warning.py
index e83dd7f446..1572463308 100755
--- a/test/functional/feature_versionbits_warning.py
+++ b/test/functional/feature_versionbits_warning.py
@@ -58,7 +58,8 @@ class VersionBitsWarningTest(BitcoinTestFramework):
def versionbits_in_alert_file(self):
"""Test that the versionbits warning has been written to the alert file."""
- alert_text = open(self.alert_filename, 'r', encoding='utf8').read()
+ with open(self.alert_filename, 'r', encoding='utf8') as f:
+ alert_text = f.read()
return VB_PATTERN.search(alert_text) is not None
def run_test(self):