python - 名称错误 : name 'StaticLiveServerCase' is not defined

标签 python django unit-testing django-testing

我正在使用 django 1.7 。我正在练习 Harry Percival 的 TDD with python 书。我正在关注这本书,但在某个地方出现了意外错误

NameError: name 'StaticLiveServerCase' is not defined

我正在寻找它,但我没有得到任何东西,有人可以告诉我这件事吗?该书第8章第131页。

最佳答案

类的名称应该是 StaticLiveServerTestCaseIt is renamed just before the 1.7 release.

我认为这本书是基于 Django 1.7 的测试版。

更新

确保导入它:

from django.contrib.staticfiles.testing import StaticLiveServerTestCase

关于python - 名称错误 : name 'StaticLiveServerCase' is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26238443/

相关文章:

python - 无法在 Google Cloud SQL 上插入数据,但 UID 字段仍在自动递增

python - 使用模式创建更大的列表列表

python - 为什么我不能在python中访问这个类成员?

c# 相当于 pythons 'a in [1, 2, 3]'

django - django rest 框架序列化程序中的 id 字段

mysql - 将 Django/MySQL 站点设置为使用 UTF-8

java - 对将序列化对象写入文件的方法进行单元测试

unit-testing - 编写难以进行单元测试的代码

python - python应用程序中脚本目录的成语?

visual-studio-2008 - 从命令行自动运行 NUnit 测试