comparison test/memorydb.py @ 5077:88fc7202f87d

Remove 'import *' statement from test/memorydb.py It is generally best to avoid 'import *' statements, particularly in this case where objects in the global namespace are being propagated through to an execfile(). The construction of the 'vars' variable is a bit of a hack, but preferable to the alternative. Sometime in the future it may be a good idea to do away with using execfile() to parse the schema files.
author John Kristensen <john@jerrykan.com>
date Fri, 10 Jun 2016 18:24:47 +1000
parents dad18ee491a9
children c0cda00af479
comparison
equal deleted inserted replaced
5076:d27de8f08c31 5077:88fc7202f87d
1 '''Implement an in-memory hyperdb for testing purposes. 1 '''Implement an in-memory hyperdb for testing purposes.
2 ''' 2 '''
3 3
4 import shutil 4 import shutil
5 5 import os
6
7 from roundup import date
6 from roundup import hyperdb 8 from roundup import hyperdb
7 from roundup import roundupdb 9 from roundup import roundupdb
8 from roundup import security 10 from roundup import security
9 from roundup import password 11 from roundup import password
10 from roundup import configuration 12 from roundup import configuration
11 from roundup.backends import back_anydbm 13 from roundup.backends import back_anydbm
12 from roundup.backends import indexer_dbm 14 from roundup.backends import indexer_dbm
13 from roundup.backends import sessions_dbm 15 from roundup.backends import sessions_dbm
14 from roundup.backends import indexer_common 16 from roundup.backends import indexer_common
15 from roundup.hyperdb import *
16 from roundup.support import ensureParentsExist 17 from roundup.support import ensureParentsExist
17 18
18 def new_config(debug=False): 19 def new_config(debug=False):
19 config = configuration.CoreConfig() 20 config = configuration.CoreConfig()
20 config.DATABASE = "db" 21 config.DATABASE = "db"
30 db = Database(new_config(debug), journaltag) 31 db = Database(new_config(debug), journaltag)
31 32
32 # load standard schema 33 # load standard schema
33 schema = os.path.join(os.path.dirname(__file__), 34 schema = os.path.join(os.path.dirname(__file__),
34 '../share/roundup/templates/classic/schema.py') 35 '../share/roundup/templates/classic/schema.py')
35 vars = dict(globals()) 36 vars = hyperdb.__dict__
37 vars['Class'] = Class
38 vars['FileClass'] = FileClass
39 vars['IssueClass'] = IssueClass
36 vars['db'] = db 40 vars['db'] = db
37 execfile(schema, vars) 41 execfile(schema, vars)
38 initial_data = os.path.join(os.path.dirname(__file__), 42 initial_data = os.path.join(os.path.dirname(__file__),
39 '../share/roundup/templates/classic/initial_data.py') 43 '../share/roundup/templates/classic/initial_data.py')
40 vars = dict(db=db, admin_email='admin@test.com', 44 vars = dict(db=db, admin_email='admin@test.com',

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