- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试做什么
我正在使用 pytest 在 python 中编写一个小型框架,作为拆解的一部分,我正在截取屏幕截图。现在,我希望根据正在运行的测试来命名该屏幕截图,而不是 conftest.py例如,我现在的代码是:
driver.save_screenshot(os.path.basename(__file__)+'.png')
问题
这会打印名称“conftest.py”。如果可能的话,我想打印调用测试的名称。我猜使用请求?
最佳答案
您可以通过request.node.fspath
访问当前文件路径。示例:
# conftest.py
import pytest
@pytest.fixture
def currpath(request):
return str(request.node.fspath)
关于python - 从conftest.py访问测试文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50393354/
我有一个很大的 conftest.py 文件,我希望将其拆分成更小的部分,原因有二: 文件非常大(约 1000 行,包括文档) 一些固定装置依赖于其他固定装置,当用户查找相关固定装置时,我没有理由将这
1、conftest.py的特点 1、可以跨.py文件调用,有多个.py文件调用时,可让conftest.py只调用了一次fixture,或调用多次fixture 2、conftest.py与
我在使用交叉编译器链接到许多库时遇到问题。是否可以在每次生成文件 conftest.c 时将其转储到安全位置? 我试图取消注释这些行 rm -f conftest 从配置脚本,但它继续像它没有任何意义
我正在尝试在计算机上运行 pytest,但 pytest 不断获取更高一级的 conftest。我正在使用的目录没有 __init__.py 17:09:36 /shared/functionalt
我的目录中有如下目录结构 tests | |__A | |__test_1.py |__B | |__test_2.py |__C | |__test3.py |__D | |__test4.
我最近发现 pytest .看起来很棒。但是,我觉得文档可能会更好。 我想了解什么 conftest.py文件旨在用于。 在我的(目前很小的)测试套件中,我有一个 conftest.py项目根目录下的
最近我一直在熟悉 pytest 以及如何使用 conftest.py 来定义在我的测试中自动发现和导入的装置。我很清楚 conftest.py 是如何工作的以及如何使用它,但我不确定为什么这被认为是某
这是我的测试目录: test/ unit/ some test files conftest.py acceptance/ some t
我想做的 pytest 总是涉及短回溯(--tb=short)和报告跳过原因(-rsx) 所以我不必每次都执行 pytest --tb=short -rsx,我可以在某个地方指定它吗,也许是 conf
我尝试在 py.test 文档测试中使用固定装置。文档中有getfixture函数,可以直接在doctests中使用。 getfixture('tmpdir') 这按预期工作。 现在我尝试使用在 co
目前,我有两个包作为我的测试存储库的一部分,其文件夹结构如下: Package_A |--__init__.py |--conftest.py |--test_A.py Package_B |--__
这是我的 API 测试目录布局: api_tests ├── conftest.py └── query └── me_test.py conftest.py 的内容: print("CONF
当我尝试运行 pytest repo/tests/test_file.py 时出现以下错误: $ pytest repo/tests/test_file.py Traceback (most rece
问题: 是否可以将 conftest.py 文件放入测试包旁边的另一个包中,如下所示? 描述 项目结构如下: ------------------------------------ GUI_pyte
我对 pytest 和创建包(模块)总体来说还很陌生。我用 pytest 编写了一些测试,这些测试运行良好,直到我重构脚本结构。这其实是有必要的,因为剧本很多,定位比较困惑。当前的目录结构如下所示:
问题: 是否可以将 conftest.py 文件放入测试包旁边的另一个包中,如下所示? 描述 项目结构如下: ------------------------------------ GUI_pyte
我有一个定义测试支持模块的项目,包括像这样的包子目录中的 py.test 插件: bokeh/_testing ├── __init__.py ├── plugins │ ├── __init__
我有一个具有以下结构的项目: Project/ | +-- src/ | | | +-- proj/ | | | +-- __init__.py | +--
我有以下目录结构 /home/ubuntu/test/ - Foo/ - Foo.py - __init__.py - Test/ - conftest.py - __in
我有myprj项目,文件如下。 $ tree myprj/ myprj/ ├── prj │ ├── __init__.py │ ├── config.py │ ├── my_logger
我是一名优秀的程序员,十分优秀!