• 课间作业

    def test_get_login():
    url="https://testerhome.com/api/v3/topics.json"
    params={"limit":3}
    r=requests.get(url,params=params)
    result=r.json()['topics'][-1]['user']['login']
    assert result == 'liangqiangWang'

    def test_xueqiu_search():
    url="https://xueqiu.com/stock/search.json"
    param={"code":"sogo","size":3,"page":1}
    header={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36",
    "Accept":"application/json",
    #"Cookie": "aliyungf_tc=AQAAAPcbdguWQQwAnonY3ZRV7lyXgyZo; acw_tc=2760822215709536378096462eed0137cd88ccae322415e4ccca9899fefad3; xq_a_token=d831cd39b53563679545656fba1f4efd8e48faa0; xq_r_token=fd2f0f487c8298cad8e7519f1560abb7a18c589d; u=371570953639944; device_id=24700f9f1986800ab4fcc880530dd0ed; Hm_lvt_1db88642e346389874251b5a1eded6e3=1570953642; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1571239059"
    }
    cookie={"xq_a_token":"d831cd39b53563679545656fba1f4efd8e48faa0"}
    result=requests.get(url,params=param,headers=header,cookies=cookie).json()
    assert result['stocks'][0]['name'] == '搜狗'

    课后作业

    def test_get_token():
    url="https://qyapi.weixin.qq.com/cgi-bin/gettoken"
    ID="xxx"
    SECRET="xxx"
    param={"corpid":ID,"corpsecret":SECRET}
    try:
    result=requests.get(url,params=param).json()
    if result["errcode"] ==0:
    access_token = result["access_token"]
    else:
    logging.info(result["errmsg"])
    except Exception as e:
    logging.error(e)
    return access_token
  • 课后作业

    import logging
    import pytest

    logging.basicConfig(level=logging.DEBUG)

    def setup_module():
    logging.info("login")

    def teardown_module():
    logging.info("整个module完成执行数据清理")

    class TestA:

    @classmethod
    def teardown_class(cls):
    logging.info("TestA_teardown 环境清理")

    def test_1(self):
    logging.info("test_1")
    assert 1==1

    def test_2(self):
    logging.info("test_2")
    assert 1 == 1

    def test_3(self):
    logging.info("test_3")
    assert 1 == 1

    class TestB:

    def setup_method(self):
    logging.info("testB_每个方法都要初始化")

    def test_4(self):
    logging.info("test_4")
    assert 1 == 1

    def test_5(self):
    logging.info("test_5")
    assert 1 == 1

    @pytest.mark.parametrize("a,b",[(2,2),(1,1),(3,4)])
    def test_6(self,a,b):
    logging.info("test_6")
    assert a == b

    class TestC:

    @pytest.mark.run(order=3)
    def test_7(self):
    logging.info("test_7")
    assert 1 == 1

    @pytest.mark.run(order=1)
    def test_8(self):
    logging.info("test_8")
    assert 1 == 2

    @pytest.mark.run(order=2)
    def test_9(self):
    logging.info("test_9")
    assert 1 == 1

    报告截图

  • 第十期_接口测试_20190926 at September 26, 2019

    课后作业1

    curl 'https://www.baidu.com/s?ie=utf-8&mod=1&isbd=1&isid=7C9066A786752741&ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=xueqiu&rsv_pq=c3ab67080003957f&rsv_t=aa89auXKlkKvllGl8OxJmebVJeZ%2B8%2FKYBIWISKmMhgGgRJSA%2BBKmT9xvhCs&rqlang=cn&rsv_enter=0&rsv_dl=tb&rsv_sug3=6&rsv_sug1=5&rsv_sug7=100&inputT=5881&rsv_sug4=5881&rsv_sid=1438_21119_29568_29221_26350&_ss=1&clist=&hsug=&f4s=1&csor=6&_cr1=29083' -H 'Cookie: BIDUPSID=7C9066112E4506F6E55251BBAE702EC8; PSTM=1572358943; BAIDUID=7C9066112E4506F6BF2A09CE33FA7867:FG=1; BD_HOME=0; BD_UPN=12314753; delPer=0; BD_CK_SAM=1; PSINO=2; BDSVRTM=46; H_PS_PSSID=1442_21117_18559_29568_29700_29221_26350; WWW_ST=1572358951776' -H 'is_xhr: 1' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: zh-CN,zh;q=0.8' -H 'User-Agent:  yangyilin' -H 'Accept: */*' -H 'Referer: https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=xueqiu&rsv_pq=c3ab67080003957f&rsv_t=aa89auXKlkKvllGl8OxJmebVJeZ%2B8%2FKYBIWISKmMhgGgRJSA%2BBKmT9xvhCs&rqlang=cn&rsv_enter=0&rsv_dl=tb&rsv_sug3=6&rsv_sug1=5&rsv_sug7=100&inputT=5881&rsv_sug4=5881' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'is_referer: https://www.baidu.com/' --compressed -vv 2>&1 |less

    课后作业2

    curl 'https://xueqiu.com/stock/search.json?code=%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4&size=3&page=1' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36' -H 'elastic-apm-traceparent: 00-a728ec9a6ae8b341e62c05b2c80b18e8-c0b0984a53ea6831-01' -H 'Accept: application/json, text/plain, */*' -H 'Referer: https://xueqiu.com/k?q=%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4' -H 'Cookie: aliyungf_tc=AQAAACfmHm7KjAYA44/Y3TSiOtUodRcN; acw_tc=2760828915723565044331123e8c5220597aedd5becf647a0dcf638ad469b1; xq_a_token=87993a504d5d350e6271c337ad8e9ec8809acb79; xq_r_token=2b9912fb63f07c0f11e94985018ad64e78cca498; __guid=125243267.2501257326310424600.1572356504105.9778; Hm_lvt_1db88642e346389874251b5a1eded6e3=1572356505; u=521572356505805; device_id=24700f9f1986800ab4fcc880530dd0ed; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1572356820; monitor_count=5' -H 'Connection: keep-alive' --compressed -vv 2>&1 |less
  • 1