[Tutor] How to test my code's interactions with SQLite db?

boB Stepp robertvstepp at gmail.com
Sun Aug 16 08:18:06 CEST 2015

Being committed to TDD for this project, I am not yet ready to write
code till I figure out how to write the tests.  It occurs to me that
writing tests for code that interacts with the SQLite db may be
non-trivial (At least for me!).  After doing some online research
tonight, it appears that I need to create a test SQLite db.  I don't
see any other way that I can test such code without having a db to
test against.  So this leads to several questions:

1) It would seem that I need to install a stand-alone version of
SQLite, so that I can create this test db.  Either that or write a
separate Python program whose sole purpose would be to create this
test db.  But if I go with installing a stand-alone SQLite, will I run
into version conflicts with whatever version of SQLite is bundled in
the standard library of Python 3.4.3?

2) If I install the test db I can conceptually see that I should be
able to test all of the Python code that interacts with it.  However,
do I need to figure out some way to test what will eventually become
the *real* db that the program will generate and use?  How will I know
if my test db structure and the resulting actual db structure that the
ultimate user(s) will populate are in agreement?  Or am I
over-analyzing here?



More information about the Tutor mailing list