From f09b3fe695d3d03379c61d10af81fd62e5fcd76e Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 10 Sep 2002 01:27:13 +0000 Subject: [PATCH] fixes to tests and Interval unmarshalling git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1115 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/date.py | 16 +++++++++----- test/test_init.py | 53 +-------------------------------------------- test/test_mailgw.py | 6 +---- 3 files changed, 13 insertions(+), 62 deletions(-) diff --git a/roundup/date.py b/roundup/date.py index 8e20c49..484889b 100644 --- a/roundup/date.py +++ b/roundup/date.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: date.py,v 1.26 2002-09-10 00:18:20 richard Exp $ +# $Id: date.py,v 1.27 2002-09-10 01:27:13 richard Exp $ __doc__ = """ Date, time and time interval handling. @@ -160,7 +160,8 @@ class Date: 2. a date from this date to produce an interval. """ if isinstance(other, Interval): - other = Interval(other.get_tuple(), sign=-other.sign) + other = Interval(other.get_tuple()) + other.sign *= -1 return self.__add__(other) assert isinstance(other, Date), 'May only subtract Dates or Intervals' @@ -315,9 +316,14 @@ class Interval: if type(spec) == type(''): self.set(spec) else: - self.sign = sign - self.year, self.month, self.day, self.hour, self.minute, \ - self.second = spec + if len(spec) == 7: + self.sign, self.year, self.month, self.day, self.hour, \ + self.minute, self.second = spec + else: + # old, buggy spec form + self.sign = sign + self.year, self.month, self.day, self.hour, self.minute, \ + self.second = spec def __cmp__(self, other): """Compare this interval to another interval.""" diff --git a/test/test_init.py b/test/test_init.py index 3cd5b27..eab0160 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: test_init.py,v 1.16 2002-09-10 00:19:54 richard Exp $ +# $Id: test_init.py,v 1.17 2002-09-10 01:27:13 richard Exp $ import unittest, os, shutil, errno, imp, sys @@ -68,86 +68,35 @@ class ClassicTestCase(MyTestCase): l = db.issue.list() ae(l, []) -class ExtendedTestCase(MyTestCase): - backend = 'anydbm' - def testCreation(self): - ae = self.assertEqual - - # create the instance - init.install(self.dirname, 'extended', self.backend) - init.initialise(self.dirname, 'sekrit') - - # check we can load the package - 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']) - l = db.status.list() - ae(l, ['1', '2', '3', '4', '5', '6', '7', '8']) - l = db.keyword.list() - ae(l, []) - l = db.user.list() - ae(l, ['1', '2']) - l = db.msg.list() - ae(l, []) - l = db.file.list() - ae(l, []) - l = db.issue.list() - ae(l, []) - l = db.support.list() - ae(l, []) - l = db.rate.list() - ae(l, ['1', '2', '3']) - l = db.source.list() - ae(l, ['1', '2', '3', '4']) - l = db.platform.list() - ae(l, ['1', '2', '3']) - l = db.timelog.list() - ae(l, []) - class bsddbClassicTestCase(ClassicTestCase): backend = 'bsddb' -class bsddbExtendedTestCase(ExtendedTestCase): - backend = 'bsddb' class bsddb3ClassicTestCase(ClassicTestCase): backend = 'bsddb3' -class bsddb3ExtendedTestCase(ExtendedTestCase): - backend = 'bsddb3' class metakitClassicTestCase(ClassicTestCase): backend = 'metakit' -class metakitExtendedTestCase(ExtendedTestCase): - backend = 'metakit' def suite(): l = [ unittest.makeSuite(ClassicTestCase, 'test'), - unittest.makeSuite(ExtendedTestCase, 'test') ] try: import bsddb l.append(unittest.makeSuite(bsddbClassicTestCase, 'test')) - l.append(unittest.makeSuite(bsddbExtendedTestCase, 'test')) except: print 'bsddb module not found, skipping bsddb DBTestCase' try: import bsddb3 l.append(unittest.makeSuite(bsddb3ClassicTestCase, 'test')) - l.append(unittest.makeSuite(bsddb3ExtendedTestCase, 'test')) except: print 'bsddb3 module not found, skipping bsddb3 DBTestCase' try: import metakit l.append(unittest.makeSuite(metakitClassicTestCase, 'test')) - l.append(unittest.makeSuite(metakitExtendedTestCase, 'test')) except: print 'metakit module not found, skipping metakit DBTestCase' diff --git a/test/test_mailgw.py b/test/test_mailgw.py index 16e9ce7..63fe8d8 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.27 2002-09-10 00:19:54 richard Exp $ +# $Id: test_mailgw.py,v 1.28 2002-09-10 01:27:13 richard Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib @@ -769,12 +769,8 @@ http://your.tracker.url.example/issue1 _________________________________________________________________________ ''') -class ExtMailgwTestCase(MailgwTestCase): - schema = 'extended' - def suite(): l = [unittest.makeSuite(MailgwTestCase), - unittest.makeSuite(ExtMailgwTestCase, 'test') ] return unittest.TestSuite(l) -- 2.30.2