open:pytest

pytest

pip install pytest

pip install pytest-cov

pytest -cov

  • 테스트 디렉토리의 이름을 tests로 지정해야 한다.
  • 테스트 파일은 test_basic.py 와 같이 접두사로 test_를 붙이거나 test.py로 끝나야 한다
  • 테스트 함수는 def test_simple()과 같이 접두사로 test_가 붙어야 한다
  • 테스트 클래스는 class TestSimple 과 같이 접두사로 Test가 붙어야 한다
  • 테스트 메서드는 함수와 동일한 규약을 따라 def test_method(self)와 같이 test_가 접두사로 붙는다

import pytest
from my_module import string_to_bool
 
true_valus=['yes','1','Yes','TRUE', 'TruE', 'True', 'true']
 
class TestStrToBool(object):
    @pytest.mark.parameterize('value', true_values)
    def test_it_detects_truish_strings(self, value)
        assert string_to_bool(value)

  • open/pytest.txt
  • 마지막으로 수정됨: 2022/01/21 04:21
  • 저자 127.0.0.1