1- # $Id: test_init.py,v 1.1 2001-08-05 07:07:58 richard Exp $
1+ # $Id: test_init.py,v 1.2 2001-08-05 07:45:27 richard Exp $
22
33import unittest , os , shutil , errno , imp , sys
44
55from roundup .init import init
66
77class MyTestCase (unittest .TestCase ):
8+ count = 0
9+ def setUp (self ):
10+ MyTestCase .count = MyTestCase .count + 1
11+ self .dirname = '_test_%s' % self .count
12+ try :
13+ shutil .rmtree (self .dirname )
14+ except OSError , error :
15+ if error .errno != errno .ENOENT : raise
16+
817 def tearDown (self ):
918 try :
10- shutil .rmtree ('_test_dir' )
19+ shutil .rmtree (self . dirname )
1120 except OSError , error :
12- if error .errno = = errno .ENOENT : raise
21+ if error .errno ! = errno .ENOENT : raise
1322
1423class ClassicTestCase (MyTestCase ):
1524 backend = 'anydbm'
1625 def testCreation (self ):
1726 ae = self .assertEqual
1827
1928 # create the instance
20- init ('_test_dir' , 'classic' , self .backend , 'sekrit' )
29+ init (self . dirname , 'classic' , self .backend , 'sekrit' )
2130
2231 # check we can load the package
23- instance = imp .load_package ('_test_dir' , '_test_dir' )
32+ instance = imp .load_package (self . dirname , self . dirname )
2433
2534 # and open the database
2635 db = instance .open ()
@@ -47,18 +56,17 @@ def testCreation(self):
4756 ae = self .assertEqual
4857
4958 # create the instance
50- init ('_test_dir' , 'extended' , self .backend , 'sekrit' )
59+ init (self . dirname , 'extended' , self .backend , 'sekrit' )
5160
5261 # check we can load the package
53- del sys .modules ['_test_dir' ]
54- instance = imp .load_package ('_test_dir' , '_test_dir' )
62+ instance = imp .load_package (self .dirname , self .dirname )
5563
5664 # and open the database
5765 db = instance .open ()
5866
5967 # check the basics of the schema and initial data set
6068 l = db .priority .list ()
61- ae (l , ['1' , '2' , '3' , '4' , '5' ])
69+ ae (l , ['1' , '2' , '3' , '4' ])
6270 l = db .status .list ()
6371 ae (l , ['1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' ])
6472 l = db .keyword .list ()
@@ -111,6 +119,10 @@ def suite():
111119
112120#
113121# $Log: not supported by cvs2svn $
122+ # Revision 1.1 2001/08/05 07:07:58 richard
123+ # added tests for roundup.init - but they're disabled until I can figure _if_
124+ # we can run them (import problems).
125+ #
114126#
115127#
116128# vim: set filetype=python ts=4 sw=4 et si
0 commit comments