11#-*- encoding: utf8 -*-
22""" Testing the jinja2 templating engine of roundup-tracker.
33
4- Copyright 2015 Bernhard E. Reiter <[email protected] > 4+ Copyright: 2016 Intevation GmbH.
5+ Author: Bernhard E. Reiter <[email protected] > 6+
57This module is Free Software under the Roundup licensing of 1.5,
68see the COPYING.txt file coming with Roundup.
79
810Just a test file template for now.
911"""
12+ import shutil # only, needed for tearDown. TODO: Remove when refactored.
1013import unittest
1114
1215import db_test_base
@@ -18,6 +21,13 @@ def test_zero(self):
1821 self .assertEqual (True , True )
1922
2023class TestCase (unittest .TestCase ):
24+ """Sets up and tears down an instance with database contents.
25+
26+ Setup and teardown modelled after the use of db_test_base
27+ by several modules like test_xmlrpc and test_userauditor.
28+
29+ TODO: Should probably be moved to a base case in db_test_base.py.
30+ """
2131
2232 backend = None # can be used to create tests per backend, see test_xmlrpc
2333
@@ -26,9 +36,19 @@ def setUp(self):
2636 self .instance = db_test_base .setupTracker (self .dirname , self .backend )
2737 self .db = self .instance .open ('admin' )
2838
39+ def tearDown (self ):
40+ self .db .close ()
41+ try :
42+ shutil .rmtree (self .dirname )
43+ except OSError , error :
44+ if error .errno not in (errno .ENOENT , errno .ESRCH ): raise
45+
2946 def test_zero (self ):
47+ """Do nothing just make sure that setup and teardown works."""
3048 pass
3149
50+
51+
3252def test_suite ():
3353 suite = unittest .TestSuite ()
3454
@@ -37,14 +57,15 @@ def test_suite():
3757 # only using one database backend for now, not sure if doing all
3858 # backends will keep the test focussed enough to be useful for the used
3959 # computing time. Would be okay to change in the future.
40- l = 'anydbm'
41- dct = dict (backend = l )
42- subcls = type (TestCase )('TestCase_%s' % l , (TestCase ,), dct )
43- suite .addTest (unittest .makeSuite (subcls ))
60+ # for l in list_backends():
61+ for l in ['anydbm' ]:
62+ dct = dict (backend = l )
63+ subcls = type (TestCase )('TestCase_%s' % l , (TestCase ,), dct )
64+ suite .addTest (unittest .makeSuite (subcls ))
4465
4566 return suite
4667
47- # Other roundup testcases do have a def main thing in there,
68+ # Other roundup test source files have an if __name__ == '__main__': here
4869# but I'm not sure if this is still helpful. So left out for now.
4970
5071# vim: ts=4 et sts=4 sw=4 ai :
0 commit comments