Change cwd before running tests
Question: I have a bunch of `unittest` test cases in separate directories. There is also
a directory which just contains helper scripts for the tests. So my file tree
looks like this

    
    
    test_dir1
    test_dir2
    test_dir3
    helper_scripts
    

Each python file in `test_dir*` will have these lines:

    
    
    import sys
    sys.path.append('../helper_scripts')
    import helper_script
    

This all works fine, as long as I run the tests from within their directory.
However, I would like to be at the project root and just run:

    
    
    py.test
    

and have it traverse all the directories and run each test it finds. The
problem is that the tests are being run from the wrong directory, so the
`sys.path.append` doesn't append the `helper_scripts` directory, it appends
the parent of the project root. This makes all the imports fail with an
`Import Error`.

Is there a way to tell `py.test` to run the test scripts from their directory?
ie. change the cwd before executing them? If not, is there another test runner
I can use that will?


Answer: 
    os.chdir("newdir")
    

will change your current working directory

