Run test_tasklistdb.py
(provided in the code distribution for this chapter). The output should be a list of test results:
python test_tasklistdb.py ...... ---------------------------------------------------------------------- Ran 6 tests in 1.312s OK
Let us look at one of the classes defined in test_tasklistdb.py
, DBentityTest
. DBentityTest
contains a number of methods starting with test_
. These are the actual tests and they verify whether some common operations like retrieving or deleting tasks behave as expected.
Chapter4/test_tasklistdb.py
from tasklistdb import TaskDB, Task, AuthenticationError, DatabaseError
import unittest
from os import unlink,close
from tempfile import mkstemp
(fileno,database) = mkstemp()
close(fileno)
class DBentityTest(unittest.TestCase):
def setUp(self):
try:
unlink(database)
except:
pass
self.t=TaskDB(database)
self.t.connect()
self.description...