# pytest-relative-path
![Languate - Python](https://img.shields.io/badge/language-python-blue.svg)
![PyPI - License](https://img.shields.io/pypi/l/pytest-relative-path)
![PyPI](https://img.shields.io/pypi/v/pytest-relative-path)
![PyPI - Downloads](https://img.shields.io/pypi/dm/pytest-relative-path)
处理Pytest参数及配置中的相对路径,将相对于执行目录改为项目项目根目录,支持时间戳。
---
### 如何使用
1. 安装 `pytest-relative-path`
使用pip安装
```sh
pip install pytest-relative-path
```
2. 在pytest命令行参数或pytest.ini配置中,路径以'.'开头,支持时间戳
```sh
pytest . --log-file=./logs/%Y%m%d%H%M%S.log
```
或在pytest.ini中配置
```ini
[pytest]
log_file=./logs/%Y%m%d%H%M%S.log
```
并执行
```sh
pytest .
```
无论执行路径,将固定在项目根目录按时间戳生成日志,例如 (rootdir)/logs/20240830122250.log
3. 支持插件pytest-html、allure-pytest、pytest-data-file、pytest-variables等,例如
```sh
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目录下寻找
Raw data
{
"_id": null,
"home_page": "https://github.com/hanzhichao/pytest-relative-path",
"name": "pytest-relative-path",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "pytest, py.test, relative path, datetime format path",
"author": "Han Zhichao",
"author_email": "superhin@126.com",
"download_url": "https://files.pythonhosted.org/packages/31/79/7d00b5e009772ffeb51a28e3758a7bd94a30b9fb8c8e9a800b78be03e6f0/pytest_relative_path-0.1.2.tar.gz",
"platform": null,
"description": "# pytest-relative-path\n\n![Languate - Python](https://img.shields.io/badge/language-python-blue.svg)\n![PyPI - License](https://img.shields.io/pypi/l/pytest-relative-path)\n![PyPI](https://img.shields.io/pypi/v/pytest-relative-path)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/pytest-relative-path)\n\n\u5904\u7406Pytest\u53c2\u6570\u53ca\u914d\u7f6e\u4e2d\u7684\u76f8\u5bf9\u8def\u5f84\uff0c\u5c06\u76f8\u5bf9\u4e8e\u6267\u884c\u76ee\u5f55\u6539\u4e3a\u9879\u76ee\u9879\u76ee\u6839\u76ee\u5f55\uff0c\u652f\u6301\u65f6\u95f4\u6233\u3002\n\n---\n\n### \u5982\u4f55\u4f7f\u7528\n\n1. \u5b89\u88c5 `pytest-relative-path`\n\n\u4f7f\u7528pip\u5b89\u88c5\n\n```sh\npip install pytest-relative-path\n```\n\n2. \u5728pytest\u547d\u4ee4\u884c\u53c2\u6570\u6216pytest.ini\u914d\u7f6e\u4e2d\uff0c\u8def\u5f84\u4ee5'.'\u5f00\u5934\uff0c\u652f\u6301\u65f6\u95f4\u6233\n\n```sh\npytest . --log-file=./logs/%Y%m%d%H%M%S.log\n```\n\n\u6216\u5728pytest.ini\u4e2d\u914d\u7f6e\n```ini\n[pytest]\nlog_file=./logs/%Y%m%d%H%M%S.log\n```\n\u5e76\u6267\u884c \n```sh\npytest .\n```\n\u65e0\u8bba\u6267\u884c\u8def\u5f84\uff0c\u5c06\u56fa\u5b9a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u6309\u65f6\u95f4\u6233\u751f\u6210\u65e5\u5fd7\uff0c\u4f8b\u5982 (rootdir)/logs/20240830122250.log\n\n3. \u652f\u6301\u63d2\u4ef6pytest-html\u3001allure-pytest\u3001pytest-data-file\u3001pytest-variables\u7b49\uff0c\u4f8b\u5982\n\n```sh\npytest . --html=./reports/TestReport-%Y%m%d%H%M%S.html --alluredir=./reports/allure_data --data-file=./data/a.json --variables=./data/b.json\n```\n\u65e0\u8bba\u6267\u884c\u8def\u5f84\u5982\u4f55\uff0c\u62a5\u544a\u4f1a\u56fa\u5b9a\u751f\u6210\u5728\u9879\u76ee/reports\u76ee\u5f55\u4e0b\uff0c\u6570\u636e\u4f1a\u56fa\u5b9a\u4ece\u9879\u76ee/data\u76ee\u5f55\u4e0b\u5bfb\u627e\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "Handle relative path in pytest options or ini configs",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/hanzhichao/pytest-relative-path"
},
"split_keywords": [
"pytest",
" py.test",
" relative path",
" datetime format path"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "31797d00b5e009772ffeb51a28e3758a7bd94a30b9fb8c8e9a800b78be03e6f0",
"md5": "8b7cf8d0ef19d8c32c6ccb677b373121",
"sha256": "95f6a6c30ae02b796b5e8b3b37762267bf44a8b11a6f5c35278f7618e61898aa"
},
"downloads": -1,
"filename": "pytest_relative_path-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "8b7cf8d0ef19d8c32c6ccb677b373121",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4702,
"upload_time": "2024-08-30T07:47:59",
"upload_time_iso_8601": "2024-08-30T07:47:59.561175Z",
"url": "https://files.pythonhosted.org/packages/31/79/7d00b5e009772ffeb51a28e3758a7bd94a30b9fb8c8e9a800b78be03e6f0/pytest_relative_path-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-30 07:47:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hanzhichao",
"github_project": "pytest-relative-path",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pytest-relative-path"
}