测试人社区

python代码疑问

涉及代码模块,项目git地址:https://github.com/YueChen-C/YamlAppium.git

class YamlFile(pytest.File):
def collect(self):
import yaml
raw = yaml.safe_load(self.fspath.open(encoding=‘utf-8’))
for name, values in raw.items():
yield YamlTest(name, self, values)

运行时错误提示如下,应该要如何优化代码
=================================== ERRORS ====================================
________________________ ERROR collecting test session ________________________
Direct construction of YamlFile has been deprecated, please use YamlFile.from_parent.
See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.
=========================== short test summary info ===========================
ERROR …
!!! Interrupted: 1 error during collection !!!
============================== 1 error in 0.60s ===============================