zoukankan      html  css  js  c++  java
  • 预处理和后处理

    import pytest
    import requests
    @pytest.fixture()
    def db():
    print("Connection successful")
    yield
    print("Connection closed")

    def search_user(user_id):
    d = {
    "001":"xiaoming",
    "002":"xiaohua",
    }
    return d[user_id]

    def test_case_01(db):
    assert search_user("001") == "xiaoming"

    def test_case_02(db):
    assert search_user("002") == "xiaohua"

    if __name__ == '__main__':
    pytest.main(["-s","test_case.py"])

    结果:

    =========================================================== test session starts ============================================================
    platform win32 -- Python 3.6.6, pytest-5.3.2, py-1.8.1, pluggy-0.13.1 -- c:python36python.exe
    cachedir: .pytest_cache
    rootdir: D:s27day68, inifile: pytest.ini, testpaths: ./scripts
    collected 2 items

    scripts/test_case.py::test_case_01 Connection successful
    PASSEDConnection closed

    scripts/test_case.py::test_case_02 Connection successful
    PASSEDConnection closed


    ============================================================ 2 passed in 0.55s =============================================================

  • 相关阅读:
    Python数据挖掘—回归—一元非线性回归
    Python数据挖掘—回归—线性回归
    Python 线程 进程 协程
    Python 异常处理
    Python Socket
    python mysql
    Python 面向对象
    Python 正则表达式
    Python 算法
    python 迭代器 生成器 装饰器
  • 原文地址:https://www.cnblogs.com/zhang-da/p/12221026.html
Copyright © 2011-2022 走看看