Merge pull request #634 from HttpRunner/fix_yaml_warning

fix: yaml FullLoader AttributeError when PyYAML version < 5.1
This commit is contained in:
debugtalk
2019-06-30 21:00:25 +08:00
committed by GitHub
3 changed files with 15 additions and 2 deletions

View File

@@ -1,5 +1,11 @@
# Release History
## 2.2.3
**Bugfixes**
- fix yaml FullLoader AttributeError when PyYAML version < 5.1
## 2.2.2 (2019-06-26)
**Features**

View File

@@ -1,7 +1,7 @@
__title__ = 'HttpRunner'
__description__ = 'One-stop solution for HTTP(S) testing.'
__url__ = 'https://github.com/HttpRunner/HttpRunner'
__version__ = '2.2.2'
__version__ = '2.2.3'
__author__ = 'debugtalk'
__author_email__ = 'mail@debugtalk.com'
__license__ = 'Apache-2.0'

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