New submission from Sergey Skripnick:

"unittest discover" does add some directories to sys.path

later some modules can not work with modified sys.path

Here module `pdb` is trying to import standard module `cmd` but does import 
`cmd` module from `tests` directory:

"unittest discover" should not modify sys.path in any way.

http://dpaste.com/2RYV8E0

$ mkdir /tmp/t
$ cd /tmp/t
$ mkdir tests
$ mkdir tests/cmd
$ touch tests/cmd/__init__.py
$ echo "import pdb" > tests/test_nothing.py
$ python -m unittest discover tests
E
======================================================================
ERROR: test_nothing (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_nothing
Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/loader.py", line 254, in _find_tests
    module = self._get_module_from_name(name)
  File "/usr/lib/python2.7/unittest/loader.py", line 232, in 
_get_module_from_name
    __import__(name)
  File "/tmp/t/tests/test_nothing.py", line 1, in <module>
    import pdb
  File "/usr/lib/python2.7/pdb.py", line 59, in <module>
    class Pdb(bdb.Bdb, cmd.Cmd):
AttributeError: 'module' object has no attribute 'Cmd'


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)

----------
messages: 243681
nosy: redixin
priority: normal
severity: normal
status: open
title: "unittest discover" does modify sys.path
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24247>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to