[Tutor] How to test my code's interactions with SQLite db?
robertvstepp at gmail.com
Mon Aug 17 02:53:46 CEST 2015
On Sun, Aug 16, 2015 at 7:36 PM, Danny Yoo <dyoo at hashcollision.org> wrote:
> 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.
I had noted this option, but I don't think I would have ever come up
with your idea on my own. Thanks!
> 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.
Likewise thanks for opening my eyes to this perspective as well!
More information about the Tutor