반응형
- Test 실행 방법
- python manage.py test
- django의 각 app에는 tests.py가 있고 거기에 Test Source를 작성하면 됩니다.
class TestView(TestCase): def test_post_list(self): self.assertEqual(2, 3)
- 결과
- 2는 3이 아니므로 Test는 Fail이 됩니다.
$ python manage.py test
Found 1 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
F
======================================================================
FAIL: test_post_list (blog.tests.TestView)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/blog/tests.py", line 6, in test_post_list
self.assertEqual(2, 3)
AssertionError: 2 != 3
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (failures=1)
Destroying test database for alias 'default'...
반응형
'Django' 카테고리의 다른 글
Django TDD beautifulsoup4 사용하기 (0) | 2022.02.19 |
---|---|
Pillow Python에서 ImageField를 사용하기 (0) | 2022.02.19 |
Django shell을 이용하여 source 실행 시키기 (0) | 2022.02.17 |
Django view에서 넘기지 않은 key 값을 구분하기 (0) | 2022.02.13 |
Django 주석 달기 (0) | 2022.02.13 |