fix: pyyaml 6.0 deprecated load without loader

This commit is contained in:
taojian
2021-11-24 14:35:51 +08:00
parent dd9ad90258
commit 13217b137e

View File

@@ -9,18 +9,12 @@ from typing import Tuple, Dict, Union, Text, List, Callable
import yaml
from loguru import logger
from pydantic import ValidationError
from yaml.loader import FullLoader
from httprunner import builtin, utils
from httprunner import exceptions
from httprunner.models import TestCase, ProjectMeta, TestSuite
try:
# PyYAML version >= 5.1
# ref: https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation
yaml.warnings({"YAMLLoadWarning": False})
except AttributeError:
pass
project_meta: Union[ProjectMeta, None] = None
@@ -30,7 +24,7 @@ def _load_yaml_file(yaml_file: Text) -> Dict:
"""
with open(yaml_file, mode="rb") as stream:
try:
yaml_content = yaml.load(stream)
yaml_content = yaml.load(stream, loader=FullLoader)
except yaml.YAMLError as ex:
err_msg = f"YAMLError:\nfile: {yaml_file}\nerror: {ex}"
logger.error(err_msg)