mirror of
https://github.com/yaml/pyyaml.git
synced 2025-11-03 18:21:00 +00:00
Use with statements to eliminate ResourceWarnings
This commit is contained in:
parent
779bdb129e
commit
575d2f46db
16 changed files with 145 additions and 91 deletions
|
|
@ -257,10 +257,12 @@ def test_constructor_types(data_filename, code_filename, verbose=False):
|
|||
native1 = None
|
||||
native2 = None
|
||||
try:
|
||||
native1 = list(yaml.load_all(open(data_filename, 'rb'), Loader=MyLoader))
|
||||
with open(data_filename, 'rb') as file:
|
||||
native1 = list(yaml.load_all(file, Loader=MyLoader))
|
||||
if len(native1) == 1:
|
||||
native1 = native1[0]
|
||||
native2 = _load_code(open(code_filename, 'rb').read())
|
||||
with open(code_filename, 'rb') as file:
|
||||
native2 = _load_code(file.read())
|
||||
try:
|
||||
if native1 == native2:
|
||||
return
|
||||
|
|
@ -284,7 +286,8 @@ test_constructor_types.unittest = ['.data', '.code']
|
|||
def test_subclass_blacklist_types(data_filename, verbose=False):
|
||||
_make_objects()
|
||||
try:
|
||||
yaml.load(open(data_filename, 'rb').read(), MyFullLoader)
|
||||
with open(data_filename, 'rb') as file:
|
||||
yaml.load(file.read(), MyFullLoader)
|
||||
except yaml.YAMLError as exc:
|
||||
if verbose:
|
||||
print("%s:" % exc.__class__.__name__, exc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue