Skip to main content

Handle relative path in pytest options or ini configs

Project description

pytest-relative-path

Languate - Python PyPI - License PyPI PyPI - Downloads

处理Pytest参数及配置中的相对路径,将相对于执行目录改为项目项目根目录,支持时间戳。


如何使用

  1. 安装 pytest-relative-path

使用pip安装

pip install pytest-relative-path
  1. 在pytest命令行参数或pytest.ini配置中,路径以'.'开头,支持时间戳
pytest . --log-file=./logs/%Y%m%d%H%M%S.log

或在pytest.ini中配置

[pytest]
log_file=./logs/%Y%m%d%H%M%S.log

并执行

pytest .

无论执行路径,将固定在项目根目录按时间戳生成日志,例如 (rootdir)/logs/20240830122250.log

  1. 支持插件pytest-html、allure-pytest、pytest-data-file、pytest-variables等,例如
pytest . --html=./reports/TestReport-%Y%m%d%H%M%S.html --alluredir=./reports/allure_data  --data-file=./data/a.json --variables=./data/b.json

无论执行路径如何,报告会固定生成在项目/reports目录下,数据会固定从项目/data目录下寻找

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_relative_path-0.1.2.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file pytest_relative_path-0.1.2.tar.gz.

File metadata

  • Download URL: pytest_relative_path-0.1.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for pytest_relative_path-0.1.2.tar.gz
Algorithm Hash digest
SHA256 95f6a6c30ae02b796b5e8b3b37762267bf44a8b11a6f5c35278f7618e61898aa
MD5 8b7cf8d0ef19d8c32c6ccb677b373121
BLAKE2b-256 31797d00b5e009772ffeb51a28e3758a7bd94a30b9fb8c8e9a800b78be03e6f0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page