Skip to content

Commit

Permalink
Merge pull request #634 from HttpRunner/fix_yaml_warning
Browse files Browse the repository at this point in the history
fix: yaml FullLoader AttributeError when PyYAML version < 5.1
  • Loading branch information
debugtalk committed Jun 30, 2019
2 parents 3b4587d + b40cb19 commit 8e01a16
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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**
Expand Down
2 changes: 1 addition & 1 deletion httprunner/__about__.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
9 changes: 8 additions & 1 deletion httprunner/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
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
###############################################################################
Expand All @@ -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

Expand Down

0 comments on commit 8e01a16

Please sign in to comment.