I have a series of unit tests that I'm running with nose. For some of my tests, I'd like to remove a module's path from the sys.path
so there is no conflict with what I am testing.
sys.path.remove('/path/to/remove/from/sys/path')
If I run the Python interpreter and call sys.path
, the '/path/to/remove/from/sys/path'
is there in the list. However, once nosetests is called, the above code cannot find it and gives me a "not found in list" error.
Why is nose not able to find the path in sys.path
?
Create a script, get_mod_py_path.py, to set the PYTHONPATH. In this case, it is dropping the conflicted path.
Then use it in a bash that calls nosetests.
Didn't you mean this?
If nose can't find it in
sys.path
then it wasn't there... nose does lots of diddling withsys.path
on its own. Why not printsys.path
and see what it actually is when run under nose