pytest
-
[Python / pytest] pytest timeout, pytest 시간 제한하기Programming/Python 2023. 5. 11. 22:35
pytest로 test 스크립트들을 짜다 보면 time과 관련된 설정을 해야 될 경우들이 있습니다. 예를 들면, 무조건 몇초이내에 실행되야 성공으로 판단되는 test case나, 중간에 잘못된 로직으로 빠지면 test가 절대 종료되지 않아 특정 시간 후에는 끊어내야 하는 그런 케이스들이 있을 수 있습니다. 이런 경우에 일정 시간 내에 테스트가 종료되지 않으면 fail 처리를 할 수 있는 방법이 있습니다. 1. 모든 테스트에 일괄된 timeout 적용 우선 pytest-timeout 모듈을 설치합니다. pip install pytest-timeout 그 후 pytest command를 실행시킬때 뒤에 timeout option을 추가하면 됩니다. pytest --timeout=10 → 위에 커맨드처럼 실행..
-
Python pytest 살펴보기, 예제 코드Programming/Python 2023. 1. 3. 16:41
안녕하세요, 오늘은 Python에서 제공하는 test library 모듈인 pytest에 대해 알아보려고 합니다. 이 글은 공식 문서인 , 아래 링크를 참조하여 정리한 글 입니다. https://docs.pytest.org/en/7.2.x/getting-started.html#request-a-unique-temporary-directory-for-functional-tests Get Started — pytest documentation Note The -q/--quiet flag keeps the output brief in this and following examples. docs.pytest.org 📍Pytest 설치하기 pip install -U pytest //pytest 버전 확인 pyte..