fix: yaml FullLoader AttributeError when PyYAML version < 5.1

This commit is contained in:
debugtalk
2019-06-30 20:53:42 +08:00
parent f02ba41724
commit b6878bd9d9
3 changed files with 15 additions and 2 deletions

View File

@@ -10,6 +10,13 @@ import sys
import yaml
from httprunner import built_in, exceptions, logger, parser, utils, validator
try:
# PyYAML version >= 5.1
# ref: https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation
yaml.warnings({'YAMLLoadWarning': False})
except AttributeError:
pass
###############################################################################
## file loader
###############################################################################
@@ -35,7 +42,7 @@ def load_yaml_file(yaml_file):
""" load yaml file and check file content format
"""
with io.open(yaml_file, 'r', encoding='utf-8') as stream:
yaml_content = yaml.load(stream, Loader=yaml.FullLoader)
yaml_content = yaml.load(stream)
_check_format(yaml_file, yaml_content)
return yaml_content