pyte-Te를 사용하여 테스트 함수의 docstring을 보고서에 출력
1. conftest.py 편집
테스트 디렉터리 바로 아래에 있는 conftest입니다.py(그렇지 않으면 생성)에 다음 설정을 추가합니다.
표 머리글의 3열에 제목, 표 주체의 3열에 테스트 함수의docsting 정보를 삽입합니다.
conftest.py
import pytest
from py.xml import html
def pytest_html_results_table_header(cells):
cells.insert(2, html.th('Description'))
def pytest_html_results_table_row(report, cells):
cells.insert(2, html.td(report.description))
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.description = str(item.function.__doc__)
2. 테스트 코드에 docstring 쓰기
def test_one(self):
"""
これはテスト1です
"""
assert True
def test_two(self):
"""
これはテスト2です
"""
assert False
3. 테스트 구현
$ pytest --html=report.html
4. 결과
표의 세 번째 열에는 각 테스트 함수의 docstring이 표시되어 있습니다.
참고 자료
Reference
이 문제에 관하여(pyte-Te를 사용하여 테스트 함수의 docstring을 보고서에 출력), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/matsuatsu/items/e0fc17bb385c350c2cf6텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)