From 67e9d3bb7d5855c1c864d686bdeeedd8a0676ace Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 5 Aug 2001 07:45:27 +0000 Subject: [PATCH] Added tests for instance initialisation git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@211 57a73879-2fb5-44c3-a270-3262357dd7e2 --- test/__init__.py | 8 +++++++- test/test_init.py | 30 +++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/test/__init__.py b/test/__init__.py index 5a9df6f..aa8f8b5 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1,14 +1,16 @@ -# $Id: __init__.py,v 1.4 2001-08-03 07:18:22 richard Exp $ +# $Id: __init__.py,v 1.5 2001-08-05 07:45:27 richard Exp $ import unittest import test_dates, test_schema, test_db, test_multipart, test_mailsplit +import test_init def go(): suite = unittest.TestSuite(( test_dates.suite(), test_schema.suite(), test_db.suite(), + test_init.suite(), test_multipart.suite(), test_mailsplit.suite(), )) @@ -17,6 +19,10 @@ def go(): # # $Log: not supported by cvs2svn $ +# Revision 1.4 2001/08/03 07:18:22 richard +# Implemented correct mail splitting (was taking a shortcut). Added unit +# tests. Also snips signatures now too. +# # Revision 1.3 2001/07/29 07:01:39 richard # Added vim command to all source so that we don't get no steenkin' tabs :) # diff --git a/test/test_init.py b/test/test_init.py index 06d792c..f943094 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -1,15 +1,24 @@ -# $Id: test_init.py,v 1.1 2001-08-05 07:07:58 richard Exp $ +# $Id: test_init.py,v 1.2 2001-08-05 07:45:27 richard Exp $ import unittest, os, shutil, errno, imp, sys from roundup.init import init class MyTestCase(unittest.TestCase): + count = 0 + def setUp(self): + MyTestCase.count = MyTestCase.count + 1 + self.dirname = '_test_%s'%self.count + try: + shutil.rmtree(self.dirname) + except OSError, error: + if error.errno != errno.ENOENT: raise + def tearDown(self): try: - shutil.rmtree('_test_dir') + shutil.rmtree(self.dirname) except OSError, error: - if error.errno == errno.ENOENT: raise + if error.errno != errno.ENOENT: raise class ClassicTestCase(MyTestCase): backend = 'anydbm' @@ -17,10 +26,10 @@ class ClassicTestCase(MyTestCase): ae = self.assertEqual # create the instance - init('_test_dir', 'classic', self.backend, 'sekrit') + init(self.dirname, 'classic', self.backend, 'sekrit') # check we can load the package - instance = imp.load_package('_test_dir', '_test_dir') + instance = imp.load_package(self.dirname, self.dirname) # and open the database db = instance.open() @@ -47,18 +56,17 @@ class ExtendedTestCase(MyTestCase): ae = self.assertEqual # create the instance - init('_test_dir', 'extended', self.backend, 'sekrit') + init(self.dirname, 'extended', self.backend, 'sekrit') # check we can load the package - del sys.modules['_test_dir'] - instance = imp.load_package('_test_dir', '_test_dir') + instance = imp.load_package(self.dirname, self.dirname) # and open the database db = instance.open() # check the basics of the schema and initial data set l = db.priority.list() - ae(l, ['1', '2', '3', '4', '5']) + ae(l, ['1', '2', '3', '4']) l = db.status.list() ae(l, ['1', '2', '3', '4', '5', '6', '7', '8']) l = db.keyword.list() @@ -111,6 +119,10 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.1 2001/08/05 07:07:58 richard +# added tests for roundup.init - but they're disabled until I can figure _if_ +# we can run them (import problems). +# # # # vim: set filetype=python ts=4 sw=4 et si -- 2.30.2