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

marker transfer incompatible with inheritance #535

pytestbot opened this Issue Jun 30, 2014 · 3 comments


2 participants
Copy link

pytestbot commented Jun 30, 2014

Originally reported by: Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt)

when a method is inherited, markers will trasnfer from the subclass to the superclass


import pytest

class TestAClass(object):

    def test_something(self):
        assert True

class TestBClass(TestAClass):

class TestCClass(TestAClass):

will skip in TestCClass (given by tradej on irc)

im not yet sure if there is a clear backward-compatible way to solve this


This comment has been minimized.

Copy link

pytestbot commented Jul 24, 2014

Original comment by BitBucket: tgoodlet, GitHub: tgoodlet:

This is particularly painful with the pytest.mark.usefixtures decorator when sibling classes require mutually exclusive dependencies.
I was wondering why would fixing this problem affect backwards compat? Isn't this just simply incorrect?
What use case would leverage this?


This comment has been minimized.

Copy link

pytestbot commented Jul 28, 2014

Original comment by BitBucket: tgoodlet, GitHub: tgoodlet:

After a decent adventure into the source I've found the guilty method to be _pytest.python.PyCollector.collect() for Instance nodes:

The test function which is actually passed to self.makeitem(name, obj) is that from the parent class definition (i.e. self.obj.__class__.__dict__) and not the current instance (i.e. self.obj).
So the callable is actually the class function definition not the unbound class method or current instance method.
Addtionally, there is an underlying check in the pytest_pycollect_makeitem hook namely, inspect.isfunction(obj) here:

This prevents modifcation of this method to simply call makeitem on the instance method...
I assume there is/was a good reason for this?
Can anyone comment on why this restriction is in place?
Also what was the original motivation behind not using the instance method directly?


This comment has been minimized.

Copy link

RonnyPfannschmidt commented Apr 10, 2018

fixed in #3317

@RonnyPfannschmidt RonnyPfannschmidt moved this from in progress to done in resolve the mark fallout Apr 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.