Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression since 1.3.1 with Python 3 #780

Closed
jd opened this issue Mar 11, 2014 · 16 comments
Closed

Regression since 1.3.1 with Python 3 #780

jd opened this issue Mar 11, 2014 · 16 comments
Milestone

Comments

@jd
Copy link

jd commented Mar 11, 2014

Hey there,

We used to have everything working with Python 3.3 and now it's broken.

Full log is at http://logs.openstack.org/28/74728/4/check/gate-oslo-incubator-python33/fcccbc2/console.html

The error we see is:

2014-03-11 14:45:38.808 | ======================================================================
2014-03-11 14:45:38.808 | ERROR: Failure: TypeError (__class__ assignment: 'UnboundSelf' object layout differs from 'TestException')
2014-03-11 14:45:38.808 | ----------------------------------------------------------------------
2014-03-11 14:45:38.808 | Traceback (most recent call last):
2014-03-11 14:45:38.808 |   File "/home/jenkins/workspace/gate-oslo-incubator-python33/.tox/py33/lib/python3.3/site-packages/nose/failure.py", line 39, in runTest
2014-03-11 14:45:38.808 |     raise self.exc_val.with_traceback(self.tb)
2014-03-11 14:45:38.809 |   File "/home/jenkins/workspace/gate-oslo-incubator-python33/.tox/py33/lib/python3.3/site-packages/nose/loader.py", line 516, in makeTest
2014-03-11 14:45:38.809 |     return self._makeTest(obj, parent)
2014-03-11 14:45:38.809 |   File "/home/jenkins/workspace/gate-oslo-incubator-python33/.tox/py33/lib/python3.3/site-packages/nose/loader.py", line 565, in _makeTest
2014-03-11 14:45:38.809 |     return self.loadTestsFromTestClass(obj)
2014-03-11 14:45:38.809 |   File "/home/jenkins/workspace/gate-oslo-incubator-python33/.tox/py33/lib/python3.3/site-packages/nose/loader.py", line 509, in loadTestsFromTestClass
2014-03-11 14:45:38.809 |     for case in filter(wanted, dir(cls))]
2014-03-11 14:45:38.809 |   File "/home/jenkins/workspace/gate-oslo-incubator-python33/.tox/py33/lib/python3.3/site-packages/nose/loader.py", line 508, in <listcomp>
2014-03-11 14:45:38.809 |     cases = [self.makeTest(getattr(cls, case), cls)
2014-03-11 14:45:38.809 |   File "/home/jenkins/workspace/gate-oslo-incubator-python33/.tox/py33/lib/python3.3/site-packages/nose/loader.py", line 504, in wanted
2014-03-11 14:45:38.809 |     item = unbound_method(cls, item)
2014-03-11 14:45:38.809 |   File "/home/jenkins/workspace/gate-oslo-incubator-python33/.tox/py33/lib/python3.3/site-packages/nose/pyversion.py", line 131, in unbound_method
2014-03-11 14:45:38.810 |     return UnboundMethod(cls, func)
2014-03-11 14:45:38.810 |   File "/home/jenkins/workspace/gate-oslo-incubator-python33/.tox/py33/lib/python3.3/site-packages/nose/pyversion.py", line 92, in __init__
2014-03-11 14:45:38.810 |     self.__self__.__class__ = cls
2014-03-11 14:45:38.810 | TypeError: __class__ assignment: 'UnboundSelf' object layout differs from 'TestException'
2014-03-11 14:45:38.810 | 
@sileht
Copy link

sileht commented Mar 11, 2014

The regression was introduce by:
c51ff6f

@jszakmeister
Copy link
Contributor

Can you provide more information about the test case that fails? Is the source for the test available somewhere? Can it be reduced to a small test case?

@jd
Copy link
Author

jd commented Mar 11, 2014

It seems to be from that file:

https://git.openstack.org/cgit/openstack/oslo-incubator/tree/tests/unit/test_policy.py

That's where TestException is defined. Didn't get deeper yet.

@jszakmeister
Copy link
Contributor

Can you try adding __test__ = False to your TestException class?

class TestException(Exception):
    __test__ = False

    def __init__(self, *args, **kwargs):
        self.args = args
        self.kwargs = kwargs

Or you can try renaming it. I think the issue here is that Nose is trying to collect the class because of the name (it's starts with Test), and it's not liking how we're wrapping it up. Perhaps we need to take a different approach, but I'm curious if that alleviates your issue.

@jd
Copy link
Author

jd commented Mar 12, 2014

@jszakmeister adding __test__ = False or renaming the exception both works.

@jszakmeister
Copy link
Contributor

Just to have it cross-referenced: the original issue being fixed was #728.

@cjw296
Copy link

cjw296 commented Mar 18, 2014

This is also a problem for me as I said on the list.
@takluyver: What's the valid use case for having a static method on a test suite?

cjw296 added a commit to simplistix/testfixtures that referenced this issue Mar 18, 2014
@takluyver
Copy link
Contributor

I believe it was a piece of test machinery we had in IPython to do a variant of parametric tests. We've since ripped it out as it was more complexity than it was worth, but the code was here: https://github.com/ipython/ipython/blob/1.x/IPython/testing/_paramtestpy3.py

@cjw296
Copy link

cjw296 commented Mar 18, 2014

So could the "fix" in #728 be reverted? maybe the docs should just be updated to say that staticmethods aren't supported on test suite classes?

@takluyver
Copy link
Contributor

I think it would be sufficient to just put that line of code inside an if not PY3: block.

@takluyver
Copy link
Contributor

I think #728 was a genuine bug, so it shouldn't be reverted, but I don't think the fix is needed in Python 3, so it should be simple.

@jszakmeister
Copy link
Contributor

@cjw296 No, I don't think it should be reverted. I believe there's another way we can approach the problem.

@takluyver
Copy link
Contributor

@jszakmeister I'm pretty sure the fix in c51ff6f was only necessary for Python 2, the equivalent in Python 3 is already set via UnboundSelf.__class__. So I think it can just do this:

if not PY3:
    self.im_class = cls

@Arfrever
Copy link

@jszakmeister: Are you planning Nose 1.3.2 release soon?

@jszakmeister
Copy link
Contributor

That's my intention. Can you test master and see that it works better for you?

@Arfrever
Copy link

All tests now pass for me with CPython 2.7, 3.1, 3.2, 3.3, 3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants