은 내가 이렇게 보이는 장고 응용 프로그램의 클래스를 기반으로보기 있습니다범위가 Djangos views.py에 아무 것도보고하지 않는 이유는 무엇입니까?
class CBView(View):
def get(self, request, client, *args, **kwargs):
output1 = self.method1(argument1)
output2 = self.method2(argument2)
# Rest of the method implementation
...
return response
def method1(self, argument1):
# Implementation
...
return output1
def method2(self, argument2):
# Implementation
...
return output2
을 그리고 나는 '쉽게'클래스 메소드, 즉 method1
및 method2
에 대한 단위 테스트를 작성하려고 해요. 테스트는 다음과 같습니다 : 그 후
class TestCBView(TestCase):
def setUp(self):
self.view = CBView()
def test_method1(self):
# Testing that output1 is as expected
...
output1 = self.view.method1(argument1)
...
self.assertEquals(output1, expected_output1)
def test_method2(self):
# Testing that output2 is as expected
...
output2 = self.view.method2(argument2)
...
self.assertEquals(output2, expected_output2)
를, 나는 실행
성공적으로 모든 테스트를 실행coverage run ./manage.py test django_app.tests.test_cbview
, 그때 내가 실행하려고 :
coverage report -m django_app/views.py
를 내가 얻을 :
Name Stmts Miss Cover Missing
-------------------------------------
No data to report.
나는 뭔가를하고있다. wro 응?
저는 Coverage.py, 버전 4.0.3, 장고 1.8.15 및 Python 2.7.13을 사용하고 있습니다.
여기를 참조하십시오 : http://stackoverflow.com/questions/7051070/why-doesnt-coverage-py-properly-measure-djangos-runserver-command –