[TIP] How to detect if you are running in "test mode"

Tim Hatch tim at timhatch.com
Wed Aug 4 15:13:07 PDT 2010


> I'm thinking of something like
> 
> PATH_TO_SCRIPTS = '/this/value/will/never/be'
> 
> if <running in testing>:
>     PATH_TO_SCRIPTS = '../some_checkout'
> else:
>     PATH_TO_SCRIPTS = '/var/lib/...../'

In my personal projects, I've generally done something like:

if os.path.exists('../some_checkout/blah.sh'):
    pass # running in development
else:
    pass # running on someone else's machine, with prereqs installed
systemwide

Tim



More information about the testing-in-python mailing list