[Tutor] How to test my code's interactions with SQLite db?
dyoo at hashcollision.org
Mon Aug 17 02:36:08 CEST 2015
By the way, when you're unit testing with Sqlite, you might find it
convenient to use the ":memory:" option, which keeps the database in
RAM rather than on disk. That should make the "setup" and "tear-down"
of the testing environment easier to maintain.
The principle is similar to that of when we're unit testing functions
whose inputs or outputs are file-like objects; although we can use
real files, we can find in-memory structures like io.StringIO useful,
since they leave no residue once the tests are completed.
More information about the Tutor