when does the database is being destroy in django

2019-08-11 01:19发布

问题:

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?