I am trying  to set up an environment variable (lets say 
"WEB2PY_USE_DB_TESTING"), so that in my db.py:

if not os.environ.get("WEB2PY_USE_DB_TESTING",None):
    db = DAL('sqlite://storage.sqlite')
else:
    db = DAL('sqlite://../fts/testdb.sqlite')

(as this resource points out:  
http://ncdegroot.blogspot.ca/2011/09/web2py-automate-unittesting-doctesting.html)

I want to set this variable by script, only when I run my functional tests.

So I have tried up to now:


   1. class FunctionalTest(unittest.TestCase):
   
       @classmethod
       def setUpClass(self):
           os.environ["WEB2PY_USE_DB_TESTING"]= "1"
           self.web2py = start_web2py_server()
           self.browser = webdriver.Firefox()
           self.browser.implicitly_wait(5)
   2. running web2py with --config=MYCONFIG, where MYCONFIG.py has:

import os
os.environ["WEB2PY_USE_DB_TESTING"]= "1"



Both methods fail to transfer the environment variable to the shell that 
web2py runs... Any suggestions?

-- 



Reply via email to