comparison test/test_mailgw.py @ 1797:c1eec970d5c0

Optimize mailgw and cgi tests... ...by creating an empty instance before the tests 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).
author Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
date Sun, 07 Sep 2003 20:37:33 +0000
parents 4de2e611b6f3
children 1a8dffd48c1c
comparison
equal deleted inserted replaced
1796:4de2e611b6f3 1797:c1eec970d5c0
6 # 6 #
7 # This module is distributed in the hope that it will be useful, 7 # This module is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # 10 #
11 # $Id: test_mailgw.py,v 1.50 2003-09-07 18:27:47 jlgijsbers Exp $ 11 # $Id: test_mailgw.py,v 1.51 2003-09-07 20:37:33 jlgijsbers Exp $
12 12
13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
14 14
15 from cStringIO import StringIO 15 from cStringIO import StringIO
16 16
17 from roundup.mailgw import MailGW, Unauthorized, uidFromAddress 17 from roundup.mailgw import MailGW, Unauthorized, uidFromAddress
18 from roundup import init, instance, rfc2822 18 from roundup import init, instance, rfc2822
19
20 NEEDS_INSTANCE = 1
19 21
20 class Message(rfc822.Message): 22 class Message(rfc822.Message):
21 """String-based Message class with equivalence test.""" 23 """String-based Message class with equivalence test."""
22 def __init__(self, s): 24 def __init__(self, s):
23 rfc822.Message.__init__(self, StringIO(s.strip())) 25 rfc822.Message.__init__(self, StringIO(s.strip()))
75 try: 77 try:
76 shutil.rmtree(self.dirname) 78 shutil.rmtree(self.dirname)
77 except OSError, error: 79 except OSError, error:
78 if error.errno not in (errno.ENOENT, errno.ESRCH): raise 80 if error.errno not in (errno.ENOENT, errno.ESRCH): raise
79 # create the instance 81 # create the instance
80 init.install(self.dirname, 'templates/classic') 82 shutil.copytree('_empty_instance', self.dirname)
81 init.write_select_db(self.dirname, 'anydbm') 83
82 init.initialise(self.dirname, 'sekrit')
83 # check we can load the package 84 # check we can load the package
84 self.instance = instance.open(self.dirname) 85 self.instance = instance.open(self.dirname)
85 # and open the database 86 # and open the database
86 self.db = self.instance.open('admin') 87 self.db = self.instance.open('admin')
87 self.db.user.create(username='Chef', address='chef@bork.bork.bork', 88 self.db.user.create(username='Chef', address='chef@bork.bork.bork',

Roundup Issue Tracker: http://roundup-tracker.org/