mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
Merge pull request #1134 from taojian-byte/master
fix: pyyaml 6.0 deprecated load without loader
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user