when does the database is being destroy in django tests?

安稳与你 提交于 2020-01-25 01:06:10

问题


i'm writing tests for my django app, and i can't understand when does the

database is destroyed..

in django website it says its being destroy "he test databases are destroyed when all the tests have been executed."

i understand from that, that the db is destroyed when the last test command in

the last test*.py file is executed.

so i wrote some tests and i have the following:

UserMethodsTests(TestCase):
    def test_get_full_name(self):
        create db objects in model X
        do some stuff on them (not deleting)

    def test_get_username(self):
        * empty line
        create more db objects in model X

but if i write "print len(X.objects.all())" in * empty line,

it output 0, as if the db was deleted..

so i don't understand if when does the db destroy/deleted

can someone help me?

来源:https://stackoverflow.com/questions/30232963/when-does-the-database-is-being-destroy-in-django-tests

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