安装 Django Fixture 时超出最大递归深度
运行 Django 单元测试时,它尝试将固定装置 (initial_data.json) 安装到数据库,但每次都会失败,因为运行时错误:调用 Python 对象时超出了最大递归深度
知道发生了什么吗?
编辑:Django 1.2.3 和 Python 2.7
When running a Django unit test, it try's to install a fixture (initial_data.json) to the db, but fails everytime due to Runtime Error: maximum recursion depth exceeded while calling Python object
Any idea what's going on?
Edit: Django 1.2.3 and Python 2.7
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我经常从
manage.py loaddata
和相关操作中收到令人沮丧的不透明错误,如您在此处所示的那样。一个可能的原因是:从
manage.py dumpdata > 生成的固定装置Fixture.json
——没有任何合格的应用程序名称——充满了测试中可能不需要的无关记录。您可能希望重新生成 initial_data.json 文件,排除以下部分或全部内容:
(这些自动重新填充时
manage.pysyncdb
之类的是调用)
权限
特别辅助您的测试(例如
我通常省略 django 标记
数据,表可能会变大
非常快,并且其内容通常与我的测试正交)
如果您需要夹具中的所有内容,您还可以尝试将其分解为两个或更多夹具文件。
I frequently get frustratingly opaque errors from
manage.py loaddata
and related operations like the one you've illustrated here.One possible cause is: fixtures generated from
manage.py dumpdata > fixture.json
-- sans any qualifying app names -- are full of extraneous records which you may not need for your tests.You may wish to regenerate your initial_data.json file, excluding some or all of the following:
(these automatically repopulate when
manage.py syncdb
and the like areinvoked)
permissions
specifically ancilliary to your tests (e.g.
I generally omit django-tagging
data, the tables for which can grow large
very quickly, and whose content is often orthogonal to my tests)
If you need everything in your fixture, you can also try breaking it into two or more fixture files.