summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dc251d5)
raw | patch | inline | side by side (parent: dc251d5)
author | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 7 Sep 2003 20:37:33 +0000 (20:37 +0000) | ||
committer | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 7 Sep 2003 20:37:33 +0000 (20:37 +0000) |
start (only if needed). In setUp(), this instance is then copied to another
directory for the actual tests.
On my system, this about halved the execution time for test_cgi (33s -> 14s)
and test_mailgw (40s -> 25s).
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1864 57a73879-2fb5-44c3-a270-3262357dd7e2
directory for the actual tests.
On my system, this about halved the execution time for test_cgi (33s -> 14s)
and test_mailgw (40s -> 25s).
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1864 57a73879-2fb5-44c3-a270-3262357dd7e2
test/__init__.py | patch | blob | history | |
test/test_cgi.py | patch | blob | history | |
test/test_mailgw.py | patch | blob | history |
diff --git a/test/__init__.py b/test/__init__.py
index 5273971e40a6667ea5b577ed78442c5f73dd9e67..90d0f01d66674425a8546563022f96702181c9b9 100644 (file)
--- a/test/__init__.py
+++ b/test/__init__.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: __init__.py,v 1.18 2002-09-10 00:19:54 richard Exp $
+# $Id: __init__.py,v 1.19 2003-09-07 20:37:33 jlgijsbers Exp $
-import os, tempfile, unittest, shutil
+import os, tempfile, unittest, shutil, errno
import roundup.roundupdb
roundup.roundupdb.SENDMAILDEBUG=os.environ['SENDMAILDEBUG']=tempfile.mktemp()
+from roundup import init
+
# figure all the modules available
dir = os.path.split(__file__)[0]
test_mods = {}
test_mods[name] = __import__(file[:-3], globals(), locals(), [])
all_tests = test_mods.keys()
+dirname = '_empty_instance'
+def create_empty_instance():
+ remove_empty_instance()
+ init.install(dirname, 'templates/classic')
+ init.write_select_db(dirname, 'anydbm')
+ init.initialise(dirname, 'sekrit')
+
+def remove_empty_instance():
+ try:
+ shutil.rmtree(dirname)
+ except OSError, error:
+ if error.errno not in (errno.ENOENT, errno.ESRCH): raise
+
def go(tests=all_tests):
- l = []
- for name in tests:
- l.append(test_mods[name].suite())
- suite = unittest.TestSuite(l)
- runner = unittest.TextTestRunner()
- runner.run(suite)
+ try:
+ l = []
+ needs_instance = 0
+ for name in tests:
+ mod = test_mods[name]
+ if hasattr(mod, 'NEEDS_INSTANCE'):
+ needs_instance = 1
+ l.append(test_mods[name].suite())
+
+ if needs_instance:
+ create_empty_instance()
+
+ suite = unittest.TestSuite(l)
+ runner = unittest.TextTestRunner()
+ runner.run(suite)
+ finally:
+ remove_empty_instance()
# vim: set filetype=python ts=4 sw=4 et si
diff --git a/test/test_cgi.py b/test/test_cgi.py
index db6081c81aeffe5089f057afac71369b9a22be87..0a5602587f879b0f558fbca784ad9e1b1b6c161f 100644 (file)
--- a/test/test_cgi.py
+++ b/test/test_cgi.py
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: test_cgi.py,v 1.18 2003-08-11 11:28:31 jlgijsbers Exp $
+# $Id: test_cgi.py,v 1.19 2003-09-07 20:37:33 jlgijsbers Exp $
import unittest, os, shutil, errno, sys, difflib, cgi, re
from roundup.cgi import client
from roundup import init, instance, password, hyperdb, date
+NEEDS_INSTANCE = 1
+
class FileUpload:
def __init__(self, content, filename):
self.content = content
except OSError, error:
if error.errno not in (errno.ENOENT, errno.ESRCH): raise
# create the instance
- init.install(self.dirname, 'templates/classic')
- init.write_select_db(self.dirname, 'anydbm')
- init.initialise(self.dirname, 'sekrit')
+ shutil.copytree('_empty_instance', self.dirname)
+
# check we can load the package
self.instance = instance.open(self.dirname)
# and open the database
diff --git a/test/test_mailgw.py b/test/test_mailgw.py
index 2fce57d68ea4d083c7df004544e72679905d5034..13cea7acf0eb0e1586d13f29472a210945a6c280 100644 (file)
--- a/test/test_mailgw.py
+++ b/test/test_mailgw.py
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: test_mailgw.py,v 1.50 2003-09-07 18:27:47 jlgijsbers Exp $
+# $Id: test_mailgw.py,v 1.51 2003-09-07 20:37:33 jlgijsbers Exp $
import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
from roundup.mailgw import MailGW, Unauthorized, uidFromAddress
from roundup import init, instance, rfc2822
+NEEDS_INSTANCE = 1
+
class Message(rfc822.Message):
"""String-based Message class with equivalence test."""
def __init__(self, s):
except OSError, error:
if error.errno not in (errno.ENOENT, errno.ESRCH): raise
# create the instance
- init.install(self.dirname, 'templates/classic')
- init.write_select_db(self.dirname, 'anydbm')
- init.initialise(self.dirname, 'sekrit')
+ shutil.copytree('_empty_instance', self.dirname)
+
# check we can load the package
self.instance = instance.open(self.dirname)
# and open the database