[py-dev] New issue 53 in py-trunk: Error during collection

issues-noreply at bitbucket.org issues-noreply at bitbucket.org
Fri Oct 9 01:33:51 CEST 2009


New issue 53: Error during collection
http://bitbucket.org/hpk42/py-trunk/issue/53/error-during-collection

Anonymous on Fri, 9 Oct 2009 01:33:51 +0200:

Description:
  The following test module causes an error during collection:

{{{
#!python

import unittest
class _E(object):
    def __getattr__(self, tag):
        pass
E = _E()
}}}

the error:

{{{
#!python

(default)l-rjones:foo richard$ py.test
================================================================= test session starts ==================================================================
python: platform darwin -- Python 2.6.1
test object 1: /private/tmp/foo

test_foo.py E

======================================================================== ERRORS ========================================================================
_________________________________________________ ERROR during collection /private/tmp/foo/test_foo.py _________________________________________________

collector = <Module 'test_foo.py'>

    def pytest_make_collect_report(collector):
        result = excinfo = None
        try:
>           result = collector._memocollect()

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/test/plugin/pytest_runner.py:32: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Module 'test_foo.py'>

    def _memocollect(self):
        """ internal helper method to cache results of calling collect(). """
>       return self._memoizedcall('_collected', self.collect)

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/test/collect.py:300: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Module 'test_foo.py'>, attrname = '_collected', function = <bound method Module.collect of <Module 'test_foo.py'>>

    def _memoizedcall(self, attrname, function):
        exattrname = "_ex_" + attrname
        failure = getattr(self, exattrname, None)
        if failure is not None:
            raise failure[0], failure[1], failure[2]
        if hasattr(self, attrname):
            return getattr(self, attrname)
        try:
>           res = function()

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/test/collect.py:99: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Module 'test_foo.py'>

    def collect(self):
        l = self._deprecated_collect()
        if l is not None:
            return l
>       name2items = self._buildname2items()

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/test/pycollect.py:94: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Module 'test_foo.py'>

    def _buildname2items(self):
        # NB. we avoid random getattrs and peek in the __dict__ instead
        d = {}
        dicts = [getattr(self.obj, '__dict__', {})]
        for basecls in py.std.inspect.getmro(self.obj.__class__):
            dicts.append(basecls.__dict__)
        seen = {}
        for dic in dicts:
            for name, obj in dic.items():
                if name in seen:
                    continue
                seen[name] = True
>               res = self.makeitem(name, obj)

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/test/pycollect.py:111: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Module 'test_foo.py'>, name = 'E', obj = <test_foo._E object at 0x758a50>

    def makeitem(self, name, obj):
        res = self.config.hook.pytest_pycollect_makeitem(
>           collector=self, name=name, obj=obj)

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/test/pycollect.py:123: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <HookCaller 'pytest_pycollect_makeitem'>

    def __call__(self, **kwargs):
        methods = self.hookrelay._getmethods(self.name, self.extralookup)
        mc = MultiCall(methods, kwargs, firstresult=self.firstresult)
>       return self.hookrelay._performcall(self.name, mc)

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/_com.py:120: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <py.__._com.HookRelay instance at 0x68ef08>, name = 'pytest_pycollect_makeitem'
multicall = <MultiCall 0 results, 0 meths, kwargs={'collector': <Module 'test_foo.py'>, '__multicall__': <MultiCall 0 results, 0 meths, kwargs={...}>, 'obj': <test_foo._E object at 0x758a50>, 'name': 'E'}>

    def _performcall(self, name, multicall):
>       return multicall.execute()

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/_com.py:105: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MultiCall 0 results, 0 meths, kwargs={'collector': <Module 'test_foo.py'>, '__multicall__': <MultiCall 0 results, 0 meths, kwargs={...}>, 'obj': <test_foo._E object at 0x758a50>, 'name': 'E'}>

    def execute(self):
        while self.methods:
            method = self.methods.pop()
            kwargs = self.getkwargs(method)
>           res = method(**kwargs)

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/_com.py:25: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

collector = <Module 'test_foo.py'>, name = 'E', obj = <test_foo._E object at 0x758a50>

    def pytest_pycollect_makeitem(collector, name, obj):
        if 'unittest' not in sys.modules:
            return # nobody could have possibly derived a subclass
>       if py.std.inspect.isclass(obj) and issubclass(obj, py.std.unittest.TestCase):
E       TypeError: issubclass() arg 1 must be a class

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py/test/plugin/pytest_unittest.py:22: TypeError
=============================================================== 1 error in 0.11 seconds ================================================================
}}}


with py.test version 1.0.2


-- 
This is an issue notification from bitbucket.org.
You are receiving this either because you are the
owner of the issue, or you are following the issue.



More information about the Pytest-dev mailing list