test, contrib, refactor: use with when opening a file

This commit is contained in:
brunoerg
2022-04-26 14:39:07 -03:00
parent 269dcad16e
commit 027aab663a
7 changed files with 54 additions and 47 deletions

View File

@ -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):