Message 104313 - Python tracker (original) (raw)

When test discovery is invoked on a package on the filesystem which is also installed in site-packages then importing the tests will look in the installed version. This causes discovery to run the wrong tests or fail.

We can detect this (compare the file against the expected location) and also insert the top level path as the first location in sys.path instead of appending it to the end.

If we detect a failed import then we should error out with an appropriate message.

(Nose gets round this by patching import to import from a specific location which seems potentially fragile.)