[New-bugs-announce] [issue10033] can't run unittest because of issubclass

danosaure report at bugs.python.org
Tue Oct 5 23:38:05 CEST 2010

New submission from danosaure <danosaure at gmail.com>:

I cannot run the simpliest test because issubclass() is always returning False in unittest.py

If i follow the documentation, the following should work.

    python -m unittest simple_test

It finds 0 tests because in unittest.py, in the following line:

            if (isinstance(obj, (type, types.ClassType)) and
                issubclass(obj, TestCase)):

and "issubclass()" always return False. The cause is "unittest" module is loaded twice. If I modify "unittest.py" to add "print", it pass in my test module and check my "class A(unittest.TestCase)".

Obviously, if I do the check interactively, it will return True.

Is there a problem with the "python -m unittest module" syntax? It seems to have two namespaces.

components: Tests
files: simple_test.py
messages: 118035
nosy: Danosaure
priority: normal
severity: normal
status: open
title: can't run unittest because of issubclass
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file19136/simple_test.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list