Skip to content

Latest commit

 

History

History
26 lines (25 loc) · 1.26 KB

2023-10-20-fri.md

File metadata and controls

26 lines (25 loc) · 1.26 KB

TIL

cafe-navigator

  • user test case 정리
  • pytest / drf unittest 비교
  • 아래의 이유로 pytest로 작성해보기로 함
    1. django 내장 test 는 Boiler Plate가 존재한다.
      • 모든 test set이 단일 클래스(django.test.TestCase)를 상속받아 운영된다.
      • 실행이 순차적으로 진행이 되다 보니 규모가 커지다 보니 느려진다.
        • pytest는 멀티 실행을 지원한다.
    2. 코드 작성이 단순해진다.
      • Django
        • 모든 test가 class 상속으로 이루어진다.
        • assert 를 각 class의 method로 평가해야 한다.
      • pytest
        • function 단위로 test를 작성 할 수 있다.
        • 단순 assert로 test를 평가할 수 있다.
    3. Django 외 다른 Python project에도 도입이 가능하다.
    4. 그 외 test config를 파일로 지정해 놓을 수 있고, fixture를 정해놓고 여러 곳에서, 원하는 순서에 맞추어 실행 시켜 볼 수 있다.
  • pytest best practice 정리
  • user signup/login test code

references

https://emimartin.me/pytest_best_practices https://djangostars.com/blog/django-pytest-testing/ https://americanopeople.tistory.com/255 https://docs.pytest.org/en/7.4.x/how-to/index.html#how-to