문제

I would like to write a test case like:

    # Create fake request with missing header that we are testing for
    request = HttpRequest() 
    request.META = {}
    response = MyApp.views.start(request)
    self.assertEqual(400, response.status_code, "Unexpected response code")

When I run the above code I see the following error message:

AttributeError: 'module' object has no attribute 'views'

I am a Python newbie and am clearly doing this wrong. Can anyone point how what the error is?

Thanks. -Raj

도움이 되었습니까?

해결책

You haven't shown your imports, or included the full traceback, which makes it harder to work out what's going wrong.

Changing

import myapp

to

import myapp.views

might work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top