当前位置: 首页 > news >正文

官网和门户网站的区别长沙3合1网站建设电话

官网和门户网站的区别,长沙3合1网站建设电话,做老师讲课视频的教育网站,长宁网站建设默认情况下,pytest 使用pytest.Package来收集包含 __init__.py 文件的目录,使用 pytest.Dir来收集其他目录。如果你想要自定义目录的收集方式,你可以编写自己的pytest.Directory 收集器,并使用 pytest_collect_directory钩子来连接…

默认情况下,pytest 使用pytest.Package来收集包含 __init__.py 文件的目录,使用 pytest.Dir来收集其他目录。如果你想要自定义目录的收集方式,你可以编写自己的pytest.Directory 收集器,并使用 pytest_collect_directory钩子来连接它。

对于目录清单文件的一个基本示例

假设你想要自定义每个目录的收集方式。以下是一个conftest.py插件的示例,它允许目录包含一个manifest.json文件,该文件定义了该目录的收集方式。在这个示例中,仅支持一个简单的文件列表,但你可以想象添加其他键,如排除项和通配符。

from __future__ import annotations  import json  import pytest  class ManifestDirectory(pytest.Directory):  def collect(self):  # pytest的标准行为是遍历所有`test_*.py`文件,并对每个文件调用`pytest_collect_file`。  # 这个收集器改为读取`manifest.json`文件,并且仅对其中定义的文件调用`pytest_collect_file`。  manifest_path = self.path / "manifest.json"  manifest = json.loads(manifest_path.read_text(encoding="utf-8"))  ihook = self.ihook  for file in manifest["files"]:  yield from ihook.pytest_collect_file(  file_path=self.path / file, parent=self  )  @pytest.hookimpl  
def pytest_collect_directory(path, parent):  # 对于包含`manifest.json`文件的目录,使用我们的自定义收集器。  if path.joinpath("manifest.json").is_file():  return ManifestDirectory.from_parent(parent=parent, path=path)  # 否则,回退到标准行为。  return None

你可以创建一个 manifest.json 文件和一些测试文件:

{"files": ["test_first.py","test_second.py"]
}
# content of test_first.py
from __future__ import annotationsdef test_1():pass
# content of test_second.py
from __future__ import annotationsdef test_2():pass
# content of test_third.py
from __future__ import annotationsdef test_3():pass

现在你可以执行测试规范了:

customdirectory $ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
rootdir: /home/sweet/project/customdirectory
configfile: pytest.ini
collected 2 itemstests/test_first.py .                                                [ 50%]
tests/test_second.py .                                               [100%]============================ 2 passed in 0.12s =============================

请注意,test_three.py 没有被执行,因为它没有在清单中列出。

你可以验证你的自定义收集器是否出现在收集树中:

customdirectory $ pytest --collect-only
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
rootdir: /home/sweet/project/customdirectory
configfile: pytest.ini
collected 2 items<Dir customdirectory><ManifestDirectory tests><Module test_first.py><Function test_1><Module test_second.py><Function test_2>======================== 2 tests collected in 0.12s ========================

http://www.yayakq.cn/news/291630/

相关文章:

  • c 网站开发的书籍青岛门户网站建设
  • 酒店 深圳 网站制作做五金标准件网站
  • 网站底部代码大全网站禁止访问
  • python基础教程学完应该学什么徐州seo培训
  • 怎样自己做网站推广企业网页制作公司
  • 网站底部有很多图标外贸圈是什么
  • 中国建设企业协会网站搜狗网址导航
  • 创建站点的基本步骤WordPress 不显示主题页
  • 温州网站建设新手如何注册个人工作室
  • 外国网站翻墙怎么做郑州企业网站
  • 建设银行车贷网站怎样免费注册网站域名
  • 对网站开发流程的认识大兴网站建设
  • 河北建设执业信息网站最专业的手机网站制作
  • 贵州省住房和建设厅网网站做se要明白网站
  • 网站建设属于什么费微信微网站教程
  • 网站建设公司专业怎么建立微信网站
  • 企业网站大图东莞市建设培训中心网站
  • 博客网站推广法广州网站建设公司哪家服务好
  • 莆田自助建站软件简单网页设计模板源代码
  • 网站优化公司信息推荐晋城做推广的网站排行
  • 凯里专注网站建设报价服装定制app排行
  • 展示型网站设计与制作团队长沙百度推广优化排名
  • 做爰全过程免费网站恢复2345网址导航
  • 门户网站开发解决方案画册排版设计模板
  • 汕头网站优化企业管理系统的构成
  • 大鹏新区住房和建设局网站WordPress实现
  • 宝安建设投资集团网站网上书店网站建设实训报告总结
  • 巩义做网站的旅游网站开发毕业设计论文
  • 建设手机网站费用吗广州企业网站建设开发
  • 网站开发职务北京自助企业建站模板