Skip to content

Commit 1c46582

Browse files
author
Richard Jones
committed
Added tests for instance initialisation
1 parent 05c1846 commit 1c46582

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

test/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
# $Id: __init__.py,v 1.4 2001-08-03 07:18:22 richard Exp $
1+
# $Id: __init__.py,v 1.5 2001-08-05 07:45:27 richard Exp $
22

33
import unittest
44

55
import test_dates, test_schema, test_db, test_multipart, test_mailsplit
6+
import test_init
67

78
def go():
89
suite = unittest.TestSuite((
910
test_dates.suite(),
1011
test_schema.suite(),
1112
test_db.suite(),
13+
test_init.suite(),
1214
test_multipart.suite(),
1315
test_mailsplit.suite(),
1416
))
@@ -17,6 +19,10 @@ def go():
1719

1820
#
1921
# $Log: not supported by cvs2svn $
22+
# Revision 1.4 2001/08/03 07:18:22 richard
23+
# Implemented correct mail splitting (was taking a shortcut). Added unit
24+
# tests. Also snips signatures now too.
25+
#
2026
# Revision 1.3 2001/07/29 07:01:39 richard
2127
# Added vim command to all source so that we don't get no steenkin' tabs :)
2228
#

test/test_init.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
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

33
import unittest, os, shutil, errno, imp, sys
44

55
from roundup.init import init
66

77
class 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

1423
class 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

Comments
 (0)