728x90

pytest 4

pytest pytest.ini, conftest.py

pytest 에서 설정 정의 등 여러가지 할 수 있게 도와주는 대표적(?) 파일들 1. pytest.ini pytest의 기본 설정을 정의 (음 node package.json이 생각났음..)# pytest.ini[pytest]addopts = -v --tb=short --maxfail=1testpaths = testsmarkers = regression: 회귀 테스트용 마커pythonpath = .addopts: 기본 옵션을 전달함, 적힌 옵션이 pytest 터미널에 입력 시 적용되는 것들이다.testpaths: pytest가 테스트를 자동으로 찾을 디렉토리를 지정 markers: 사용자 정의 마커이며 @pytest.mark.regression로 적힌 test를 모아서 진행할 수 있고, pytes..

Programming/Pytest 2024.10.27

@pytest.fixture

Pytest Fixture란?fixture는 setup과 teardown 작업을 수행하는 데 사용되는 데코레이터로 사용된다.즉, 아래와 같은 형태로 sampe_fixture에서 return한 data 를 test_sample의 인자로 전달 후, 사용할 수 있다는 의미import pytest@pytest.fixturedef sample_fixture(): data = {"key": "value"} return datadef test_sample(sample_fixture): assert sample_fixture["key"] == "value" 어떻게 보면 cypress 등에 beforeEach 등으로 보면 될 듯. 말그대로 테스트 시작전 setup을 하거나 하는 형태로, 물론 위에 써둔 ..

Programming/Pytest 2024.07.14

Pytest

Python 에 있는 테스트 프레임워크 중 하나로 함수로 작성하면 되니까 생각보다 편리하다.unittest 는 Junit 을 참고한 테스트 프레임워크다보니, class 형태로 작성을 하며, 무려 python이지만 카멜케이스로 작성한다. 여어어어트으은.. 간략하게 pytest 맛보기 stable 사이트에 명시 된 require는 pytest requires: Python 3.8+ or PyPy3. 이렇다.https://docs.pytest.org/en/stable/index.html(얜 왜 미리보기 안됌...)테스트 환경에 python 프로젝트를 생성 후, 아래 pip를 통해 pytest를 설치한다.pip install -U pytest test_1.py 파일에 대충 공식 사이트에 있는 예제를 써보고 de..

Programming/Pytest 2024.07.12
728x90