Moving test sys.path/env setup

This commit is contained in:
Andrew Melton 2013-01-25 16:36:07 -05:00
parent fbeb83fa43
commit 9117fd408c
4 changed files with 22 additions and 17 deletions

BIN
.coverage

Binary file not shown.

View File

@ -0,0 +1,22 @@
import os
import sys
def setup_sys_path():
sys.path = [os.path.abspath(os.path.dirname('stacktach'))] + sys.path
def setup_environment():
'''Other than the settings module, these config settings just need
to have values. The are used when the settings module is loaded
and then never again.'''
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
os.environ['STACKTACH_DB_ENGINE'] = ''
os.environ['STACKTACH_DB_NAME'] = ''
os.environ['STACKTACH_DB_HOST'] = ''
os.environ['STACKTACH_DB_USERNAME'] = ''
os.environ['STACKTACH_DB_PASSWORD'] = ''
os.environ['STACKTACH_INSTALL_DIR'] = ''
setup_sys_path()
setup_environment()

View File

@ -2,7 +2,6 @@ import datetime
import decimal
import unittest
import utils
from stacktach import datetime_to_decimal
class DatetimeToDecimalTestCase(unittest.TestCase):

View File

@ -5,22 +5,6 @@ import unittest
TENANT_ID_1 = 'testtenantid1'
def setup_sys_path():
sys.path = [os.path.abspath(os.path.dirname('stacktach'))] + sys.path
def setup_environment():
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
os.environ['STACKTACH_DB_ENGINE'] = 'django.db.backends.sqlite3'
when = str(datetime.datetime.utcnow())
os.environ['STACKTACH_DB_NAME'] = '/tmp/stacktach.%s.sqlite' % when
os.environ['STACKTACH_DB_HOST'] = ''
os.environ['STACKTACH_DB_USERNAME'] = ''
os.environ['STACKTACH_DB_PASSWORD'] = ''
install_dir = os.path.abspath(os.path.dirname('stacktach'))
os.environ['STACKTACH_INSTALL_DIR'] = install_dir
setup_sys_path()
setup_environment()
from stacktach import datetime_to_decimal as dt
INSTANCE_ID_1 = 'testinstanceid1'