代码改变世界

python logging打印不出来

2020-09-06 10:43  HQS_blog  阅读(2633)  评论(2编辑  收藏  举报
import requests
import logging
import pytest


class TestRequest(object):
    logging.basicConfig(level=logging.INFO)

    def test_getRequest(self):
        print("111111111")
        logging.info("Start print log")
        params_get = {"limit": 2}
        r = requests.get(url="https://testerhome.com/api/v3/topics.json", params=params_get)
        logging.info(r)
        logging.info(r.json())


# if __name__ == '__mian__':
#     print("5678992345678")
#     TestRequest.test_getRequest()

 

运行结果

Testing started at 10:39 ...
E:\tools\Python\pydata\huogecase\venv\Scripts\python.exe E:\tools\Python\JetBrains\PyCharm2020\plugins\python\helpers\pycharm\_jb_pytest_runner.py --path E:/tools/Python/pydata/huogecase/test_requests/test_get_requests.py
Launching pytest with arguments E:/tools/Python/pydata/huogecase/test_requests/test_get_requests.py in E:\tools\Python\pydata\huogecase\test_requests

============================= test session starts =============================
platform win32 -- Python 3.5.0, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- E:\tools\Python\pydata\huogecase\venv\Scripts\python.exe
cachedir: .pytest_cache
rootdir: E:\tools\Python\pydata\huogecase\test_requests
collecting ... collected 1 item

test_get_requests.py::TestRequest::test_getRequest

============================== 1 passed in 0.87s ==============================

Process finished with exit code 0
PASSED [100%]111111111

 

 

 

打印出来111111111表示  test_getRequest 方法已经执行了,但是logging打印不出来,暂时没看出来问题,以后再解决吧