0

我想写一个测试用例,例如:

    # 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")

当我运行上面的代码时,我看到以下错误消息:

AttributeError:“模块”对象没有属性“视图”

我是 Python 新手,显然做错了。谁能指出错误是什么?

谢谢。-拉吉

4

1 回答 1

2

您没有显示您的导入,也没有包含完整的回溯,这使得找出问题所在变得更加困难。

改变

import myapp

import myapp.views

可能会奏效。

于 2014-01-28T22:17:35.007 回答