This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author redixin
Recipients redixin
Date 2015-05-20.18:11:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1432145504.49.0.0792649435806.issue24247@psf.upfronthosting.co.za>
In-reply-to
Content
"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)
History
Date User Action Args
2015-05-20 18:11:44redixinsetrecipients: + redixin
2015-05-20 18:11:44redixinsetmessageid: <1432145504.49.0.0792649435806.issue24247@psf.upfronthosting.co.za>
2015-05-20 18:11:44redixinlinkissue24247 messages
2015-05-20 18:11:44redixincreate