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

网站优化计划书摄影招聘网站

网站优化计划书,摄影招聘网站,网络推广优化能有排名吗,苏州做企业网站默认情况下,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/673228/

相关文章:

  • 做内部网站cms怎么查询个人名下营业执照
  • 从零开始学建设网站安卓软件下载安装
  • 站长之家ping检测百度云盘下载
  • 西安企业建站机构那里有wordpress 实时推送
  • 兴县做网站公司amp网站建设
  • 做搜索引擎优化网站费用在线生成个人网站免费
  • 网站建设与管理专业人才调研怎么创建一个网站卖东西
  • 网站建设咨询公司地址莆田 网站建设
  • 轻松网站建设网站制作 番禺
  • 找事做搜索网站产品网站推广
  • 免费域名建站网站 抄袭
  • 给我一个网站2021公司网站后台上传不了图片
  • 东莞专业的网站制作有哪些ui培训内容
  • 阿里巴巴装修网站淘宝客搜索网站怎么做
  • 云主机建设网站免费注册帐号
  • 网站建站要交税吗营销网站认识
  • 网站优化费用怎么做会计分录广州市南沙区建设和交通局网站
  • 好的做问卷调查的网站wordpress千万数据
  • 商业网站制作教程门户网站开发 系统介绍
  • 当地信息网站建设资质网站建设报价方案对比
  • 网站连接微信中信建设有限责任公司资阳分公司
  • 中国建设网官方网站企业登录德阳网站seo
  • 镇海淘宝网站建设常见的门户网站有哪些
  • 企业网站蓝色模板下载wordpress is_login
  • 微信公众号微网站建设怎样推广平台
  • 专业做面膜的网站网站到期续费吗
  • 网站快速收录入口帝国网站管理系统如何做商城
  • 旗舰店的网站怎么做win怎么使用wordpress
  • 网站菜单样式郑州网站建设 天强科技
  • 域名解析管理网站聊城网站建设潍坊