comparison test/test_cgi.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 5a04969176dc
children e24cebaaa7e8
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_cgi.py,v 1.18 2003-08-11 11:28:31 jlgijsbers Exp $ 11 # $Id: test_cgi.py,v 1.19 2003-09-07 20:37:33 jlgijsbers Exp $
12 12
13 import unittest, os, shutil, errno, sys, difflib, cgi, re 13 import unittest, os, shutil, errno, sys, difflib, cgi, re
14 14
15 from roundup.cgi import client 15 from roundup.cgi import client
16 from roundup import init, instance, password, hyperdb, date 16 from roundup import init, instance, password, hyperdb, date
17
18 NEEDS_INSTANCE = 1
17 19
18 class FileUpload: 20 class FileUpload:
19 def __init__(self, content, filename): 21 def __init__(self, content, filename):
20 self.content = content 22 self.content = content
21 self.filename = filename 23 self.filename = filename
63 try: 65 try:
64 shutil.rmtree(self.dirname) 66 shutil.rmtree(self.dirname)
65 except OSError, error: 67 except OSError, error:
66 if error.errno not in (errno.ENOENT, errno.ESRCH): raise 68 if error.errno not in (errno.ENOENT, errno.ESRCH): raise
67 # create the instance 69 # create the instance
68 init.install(self.dirname, 'templates/classic') 70 shutil.copytree('_empty_instance', self.dirname)
69 init.write_select_db(self.dirname, 'anydbm') 71
70 init.initialise(self.dirname, 'sekrit')
71 # check we can load the package 72 # check we can load the package
72 self.instance = instance.open(self.dirname) 73 self.instance = instance.open(self.dirname)
73 # and open the database 74 # and open the database
74 self.db = self.instance.open('admin') 75 self.db = self.instance.open('admin')
75 self.db.user.create(username='Chef', address='chef@bork.bork.bork', 76 self.db.user.create(username='Chef', address='chef@bork.bork.bork',

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