tep


Nametep JSON
Version 3.0.3 PyPI version JSON
download
home_pagehttps://github.com/dongfanger/tep
Summarytep is a testing framework to help you write pytest more easily. Try Easy Pytest!
upload_time2025-01-03 14:04:36
maintainerNone
docs_urlNone
authordongfanger
requires_python<4.0,>=3.8
licenseApache-2.0
keywords testing http framework pytest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 简介

tep是Try Easy Pytest的首字母缩写,帮你轻松上手pytest。

框架特点:

- 基于pytest封装,成熟、稳定且扩展性强。
- 框架完全由Python构建,没有混杂其他语言。
- 原生Python语法,学习Python,零成本使用框架。
- HAR包转换pytest用例。
- 函数v()支持${}占位符语法,便捷管理接口数据。

# 安装

支持Python3.8以上版本

创建虚拟环境:`python -m venv .venv`

激活虚拟环境,Windows用户:`activate.bat` Mac用户:`source .venv/bin/activate`

安装tep:`pip install tep`

验证安装成功:`tep -V`

用例示范:

```python
import json

from tep import request
from tep import step
from tep import v

from data.global_data import GlobalData


class Data:
    v({
        "domain": GlobalData.domain,
        "skuNum": 2,
        "payAmount": 0.2
    })
    body_add_cart = """
{
    "skuId": "${skuId}",
    "skuNum":${skuNum}
}
"""
    body_order = """
{
    "skuId": "${skuId}",
    "price":${skuPrice},
    "skuNum":${skuNum},
    "totalPrice":${totalPrice}
}
"""
    body_pay = """
{
    "orderId": "${orderId}",
    "payAmount":${payAmount}
}
"""


def test():
    step("查询商品", step_search_sku)
    step("添加购物车", step_add_cart)
    step("下单", step_order)
    step("支付", step_pay)


def step_search_sku():
    url = v("${domain}/searchSku?skuName=book")
    response = request("get", url=url, headers=GlobalData.headers)
    assert response.status_code < 400
    v("skuId", response.jsonpath("$.skuId")[0])
    v("skuPrice", response.jsonpath("$.price")[0])


def step_add_cart():
    url = v("${domain}/addCart")
    body = v(Data.body_add_cart)
    response = request("post", url=url, headers=GlobalData.headers, json=json.loads(body))
    assert response.status_code < 400
    v("skuNum", response.jsonpath("$.skuNum")[0])
    v("totalPrice", response.jsonpath("$.totalPrice")[0])


def step_order():
    url = v("${domain}/order")
    body = v(Data.body_order)
    response = request("post", url=url, headers=GlobalData.headers, json=json.loads(body))
    assert response.status_code < 400
    v("orderId", response.jsonpath("$.orderId")[0])


def step_pay():
    url = v("${domain}/pay")
    body = v(Data.body_pay)
    response = request("post", url=url, headers=GlobalData.headers, json=json.loads(body))
    assert response.status_code < 400
    assert response.jsonpath("$.success")[0] == "true"
```

# 更多介绍

[原创接口测试框架tep](https://dongfanger.github.io/chapters/%E5%8E%9F%E5%88%9B%E6%8E%A5%E5%8F%A3%E6%B5%8B%E8%AF%95%E6%A1%86%E6%9E%B6tep.html)

# 重要版本说明

- V3.0.0 纯粹Python接口测试框架
- V2.0.0 关键字驱动框架
- V1.0.0 tep小工具完整教程
- V0.2.3 tep小工具首次开源
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dongfanger/tep",
    "name": "tep",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "testing, http, framework, pytest",
    "author": "dongfanger",
    "author_email": "dongfanger@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/86/65/4562b7056412c84e79a5521a1d43d7f2cc82a557cd7645cbed45f461c7e9/tep-3.0.3.tar.gz",
    "platform": null,
    "description": "# \u7b80\u4ecb\n\ntep\u662fTry Easy Pytest\u7684\u9996\u5b57\u6bcd\u7f29\u5199\uff0c\u5e2e\u4f60\u8f7b\u677e\u4e0a\u624bpytest\u3002\n\n\u6846\u67b6\u7279\u70b9\uff1a\n\n- \u57fa\u4e8epytest\u5c01\u88c5\uff0c\u6210\u719f\u3001\u7a33\u5b9a\u4e14\u6269\u5c55\u6027\u5f3a\u3002\n- \u6846\u67b6\u5b8c\u5168\u7531Python\u6784\u5efa\uff0c\u6ca1\u6709\u6df7\u6742\u5176\u4ed6\u8bed\u8a00\u3002\n- \u539f\u751fPython\u8bed\u6cd5\uff0c\u5b66\u4e60Python\uff0c\u96f6\u6210\u672c\u4f7f\u7528\u6846\u67b6\u3002\n- HAR\u5305\u8f6c\u6362pytest\u7528\u4f8b\u3002\n- \u51fd\u6570v()\u652f\u6301${}\u5360\u4f4d\u7b26\u8bed\u6cd5\uff0c\u4fbf\u6377\u7ba1\u7406\u63a5\u53e3\u6570\u636e\u3002\n\n# \u5b89\u88c5\n\n\u652f\u6301Python3.8\u4ee5\u4e0a\u7248\u672c\n\n\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a`python -m venv .venv`\n\n\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff0cWindows\u7528\u6237\uff1a`activate.bat` Mac\u7528\u6237\uff1a`source .venv/bin/activate`\n\n\u5b89\u88c5tep\uff1a`pip install tep`\n\n\u9a8c\u8bc1\u5b89\u88c5\u6210\u529f\uff1a`tep -V`\n\n\u7528\u4f8b\u793a\u8303\uff1a\n\n```python\nimport json\n\nfrom tep import request\nfrom tep import step\nfrom tep import v\n\nfrom data.global_data import GlobalData\n\n\nclass Data:\n    v({\n        \"domain\": GlobalData.domain,\n        \"skuNum\": 2,\n        \"payAmount\": 0.2\n    })\n    body_add_cart = \"\"\"\n{\n    \"skuId\": \"${skuId}\",\n    \"skuNum\":${skuNum}\n}\n\"\"\"\n    body_order = \"\"\"\n{\n    \"skuId\": \"${skuId}\",\n    \"price\":${skuPrice},\n    \"skuNum\":${skuNum},\n    \"totalPrice\":${totalPrice}\n}\n\"\"\"\n    body_pay = \"\"\"\n{\n    \"orderId\": \"${orderId}\",\n    \"payAmount\":${payAmount}\n}\n\"\"\"\n\n\ndef test():\n    step(\"\u67e5\u8be2\u5546\u54c1\", step_search_sku)\n    step(\"\u6dfb\u52a0\u8d2d\u7269\u8f66\", step_add_cart)\n    step(\"\u4e0b\u5355\", step_order)\n    step(\"\u652f\u4ed8\", step_pay)\n\n\ndef step_search_sku():\n    url = v(\"${domain}/searchSku?skuName=book\")\n    response = request(\"get\", url=url, headers=GlobalData.headers)\n    assert response.status_code < 400\n    v(\"skuId\", response.jsonpath(\"$.skuId\")[0])\n    v(\"skuPrice\", response.jsonpath(\"$.price\")[0])\n\n\ndef step_add_cart():\n    url = v(\"${domain}/addCart\")\n    body = v(Data.body_add_cart)\n    response = request(\"post\", url=url, headers=GlobalData.headers, json=json.loads(body))\n    assert response.status_code < 400\n    v(\"skuNum\", response.jsonpath(\"$.skuNum\")[0])\n    v(\"totalPrice\", response.jsonpath(\"$.totalPrice\")[0])\n\n\ndef step_order():\n    url = v(\"${domain}/order\")\n    body = v(Data.body_order)\n    response = request(\"post\", url=url, headers=GlobalData.headers, json=json.loads(body))\n    assert response.status_code < 400\n    v(\"orderId\", response.jsonpath(\"$.orderId\")[0])\n\n\ndef step_pay():\n    url = v(\"${domain}/pay\")\n    body = v(Data.body_pay)\n    response = request(\"post\", url=url, headers=GlobalData.headers, json=json.loads(body))\n    assert response.status_code < 400\n    assert response.jsonpath(\"$.success\")[0] == \"true\"\n```\n\n# \u66f4\u591a\u4ecb\u7ecd\n\n[\u539f\u521b\u63a5\u53e3\u6d4b\u8bd5\u6846\u67b6tep](https://dongfanger.github.io/chapters/%E5%8E%9F%E5%88%9B%E6%8E%A5%E5%8F%A3%E6%B5%8B%E8%AF%95%E6%A1%86%E6%9E%B6tep.html)\n\n# \u91cd\u8981\u7248\u672c\u8bf4\u660e\n\n- V3.0.0 \u7eaf\u7cb9Python\u63a5\u53e3\u6d4b\u8bd5\u6846\u67b6\n- V2.0.0 \u5173\u952e\u5b57\u9a71\u52a8\u6846\u67b6\n- V1.0.0 tep\u5c0f\u5de5\u5177\u5b8c\u6574\u6559\u7a0b\n- V0.2.3 tep\u5c0f\u5de5\u5177\u9996\u6b21\u5f00\u6e90",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "tep is a testing framework to help you write pytest more easily. Try Easy Pytest!",
    "version": "3.0.3",
    "project_urls": {
        "Homepage": "https://github.com/dongfanger/tep",
        "Repository": "https://github.com/dongfanger/tep"
    },
    "split_keywords": [
        "testing",
        " http",
        " framework",
        " pytest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "609106fe1e73fa0433f613539064df1cc3221abd6645cef7d28c2f410e278294",
                "md5": "6e6264dd5596c6c2635acb199844e3a2",
                "sha256": "dadc32673dd9b1ef46908e1ae16ef34a7423cebddf0831b875f96fcc509054b4"
            },
            "downloads": -1,
            "filename": "tep-3.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6e6264dd5596c6c2635acb199844e3a2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 29489,
            "upload_time": "2025-01-03T14:04:34",
            "upload_time_iso_8601": "2025-01-03T14:04:34.139301Z",
            "url": "https://files.pythonhosted.org/packages/60/91/06fe1e73fa0433f613539064df1cc3221abd6645cef7d28c2f410e278294/tep-3.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "86654562b7056412c84e79a5521a1d43d7f2cc82a557cd7645cbed45f461c7e9",
                "md5": "fdce72e4aaccdd793bb1c4bddde0af03",
                "sha256": "1f0c25dff547b43db16b3e98e25e414ff45bdbdda995d0b4876ad2b603b55d32"
            },
            "downloads": -1,
            "filename": "tep-3.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "fdce72e4aaccdd793bb1c4bddde0af03",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 26224,
            "upload_time": "2025-01-03T14:04:36",
            "upload_time_iso_8601": "2025-01-03T14:04:36.886428Z",
            "url": "https://files.pythonhosted.org/packages/86/65/4562b7056412c84e79a5521a1d43d7f2cc82a557cd7645cbed45f461c7e9/tep-3.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-03 14:04:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dongfanger",
    "github_project": "tep",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tep"
}
        
Elapsed time: 0.39081s