Django Test Database looks empty while test is runnin

感情迁移 提交于 2020-01-22 18:25:21

问题


I have a Django project that uses local PostgreSQL server. I'm using a debugger to debug some weird bugs that I have. While the debugger is stopped on one of the tests, I tried to look at the test database. I see this new database (test_project1) and all the schemes are defined as they should be. But all tables are empty.

I know that the tables are not empty: - I used fixture and some tests already ran and returned data. - A post test created new user returned 201 status code.

And yet, I see no data when I try to access the database with pgAdmin3 or psql.

Any idea what is going on here? Is there some kind of sophisticated cash mechanism that Django uses?


回答1:


Django's TestCase is wrapping every test in its own transaction. So your database is not being used any time you do a request through ORM.



来源:https://stackoverflow.com/questions/10367338/django-test-database-looks-empty-while-test-is-runnin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!