Django: Getting Started Transcripts
Chapter: Django ORM and Databases
Lecture: Running the 'stringify' test

Login or purchase this course to watch this video and the rest of the course contents.
0:00 To show you the difference between the test database and the project database. Let me start by showing you the project database.
0:12 Yet another handy method for the query manager. This one counts all the objects. There are still three books, back out to the shell,
0:21 and now I'll run the stringify test. Okay, lots going on here. First off you can explicitly call a single test by naming it.
0:38 Here, that's the tests module. The tests, catalog module inside of it, the catalog test case class inside of that file.
0:47 And this test stringify method of the catalog test case class, it's a lot of typing but it gets you to a single test.
0:58 The first three lines come from the test suite. Then there's a long line of equal signs. Underneath that, you'll see the debug from the setup method
1:07 at the beginning of setup there are no books and no authors. By the end of setup there are one of each.
1:16 Then test stringify gets called and it says there's one book and one author.
1:20 Those are the ones created by setup and because test stringify didn't create anything new, one book and one author on the way out.
1:30 Our real database has one author and three books. Our test database starts out empty and then set up creates McTest and her book.


Talk Python's Mastodon Michael Kennedy's Mastodon