Use with statements to eliminate ResourceWarnings

This commit is contained in:
Thom Smith 2021-09-22 16:32:47 -04:00 committed by Ingy döt Net
parent 779bdb129e
commit 575d2f46db
16 changed files with 145 additions and 91 deletions

View file

@ -29,8 +29,10 @@ class Multi2(yaml.FullLoader):
pass
def test_multi_constructor(input_filename, code_filename, verbose=False):
input = open(input_filename, 'rb').read().decode('utf-8')
native = _load_code(open(code_filename, 'rb').read())
with open(input_filename, 'rb') as file:
input = file.read().decode('utf-8')
with open(code_filename, 'rb') as file:
native = _load_code(file.read())
# default multi constructor for ! and !! tags
Multi1.add_multi_constructor('!', myconstructor1)