pytest-testdata


Namepytest-testdata JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/hanzhichao/pytest-testdata
SummaryGet and load testdata in pytest projects
upload_time2024-08-30 08:18:17
maintainerNone
docs_urlNone
authorHan Zhichao
requires_pythonNone
licenseMIT license
keywords pytest py.test relative path datetime format path
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytest-testdata

![Languate - Python](https://img.shields.io/badge/language-python-blue.svg)
![PyPI - License](https://img.shields.io/pypi/l/pytest-testdata)
![PyPI](https://img.shields.io/pypi/v/pytest-testdata)
![PyPI - Downloads](https://img.shields.io/pypi/dm/pytest-testdata)

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

---

### 如何使用

1. 安装 `pytest-testdata`

使用pip安装

```sh
pip install pytest-testdata
```

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-testdata",
    "name": "pytest-testdata",
    "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/82/40/cb7b3c3d30d02a341d1023a603007e2041e846f18590f58da560e65bc7a6/pytest_testdata-0.1.1.tar.gz",
    "platform": null,
    "description": "# pytest-testdata\n\n![Languate - Python](https://img.shields.io/badge/language-python-blue.svg)\n![PyPI - License](https://img.shields.io/pypi/l/pytest-testdata)\n![PyPI](https://img.shields.io/pypi/v/pytest-testdata)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/pytest-testdata)\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-testdata`\n\n\u4f7f\u7528pip\u5b89\u88c5\n\n```sh\npip install pytest-testdata\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": "Get and load testdata in pytest projects",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/hanzhichao/pytest-testdata"
    },
    "split_keywords": [
        "pytest",
        " py.test",
        " relative path",
        " datetime format path"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8240cb7b3c3d30d02a341d1023a603007e2041e846f18590f58da560e65bc7a6",
                "md5": "a4a2112345cc83d652bc85298f7a2ab6",
                "sha256": "dcef08c9f63d7d169cf29bea960fde52a5a0f5b2f36e26db964d72fc9bf0b6e8"
            },
            "downloads": -1,
            "filename": "pytest_testdata-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a4a2112345cc83d652bc85298f7a2ab6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3798,
            "upload_time": "2024-08-30T08:18:17",
            "upload_time_iso_8601": "2024-08-30T08:18:17.908300Z",
            "url": "https://files.pythonhosted.org/packages/82/40/cb7b3c3d30d02a341d1023a603007e2041e846f18590f58da560e65bc7a6/pytest_testdata-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-30 08:18:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hanzhichao",
    "github_project": "pytest-testdata",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "pytest-testdata"
}
        
Elapsed time: 4.52695s