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 =============================================================

  • 相关阅读:
    [hdu5312]数的拆分,数学推导
    [POJ1038]状压DP
    [hdu2112]最短路
    [hdu1532]最大流
    [hdu5256]LIS模型
    [hdu5255]枚举
    [hdu5254]BFS
    [hdu5270]按位统计,容斥,归并
    Elasticsearch在Centos 7上的安装与配置
    手动安装java1.8
  • 原文地址:https://www.cnblogs.com/zhang-da/p/12221026.html
Copyright © 2011-2022 走看看