Add to PYTHONPATH for tests?

Gary Oberbrunner garyo at genarts.com
Fri Jul 27 21:04:37 UTC 2007


I'm subclassing Test, and I'd like to execute some python tests via the shell.
 However I need them to have the QMTest dir in their PYTHONPATH.  Is there a
QMtest-approved way to tweak PYTHONPATH, or should I just do this:

class Test(test.Test):
    """Simple test that runs a python script and checks the status
    to determine whether the test passes."""

...
    def Run(self, context, result):
        """Run the test"

        env = os.environ.copy()
        env['PYTHONPATH'] = os.path.join(os.getcwd(), 'QMTest')
        args = [context.get('python', sys.executable), self.script]
        command = RedirectedExecutable()
        status = command.Run(args, env)
        ...

Any hints?

-- 
Gary Oberbrunner



More information about the qmtest mailing list