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

Marks don't pick up nested classes #199

Closed
pytestbot opened this issue Oct 5, 2012 · 13 comments
Closed

Marks don't pick up nested classes #199

pytestbot opened this issue Oct 5, 2012 · 13 comments
Labels
topic: marks related to marks, either the general marks or builtin type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Anonymous


example:

#!python

@pytest.mark.a
class TestA:
    def test_b(self):
        assert True
    class TestC:
        def test_d(self):
            assert True

#!bash

$ py.test example.py -m a

only test_b is run. Not test_d


@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


i identified the internal transfer_markers function as the problem

we should probably completely kill it in favor of the NodeKeywords mechanism

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


problem is compatibility - we should first allow to access markers conveniently without accessing a func's dict - this is already possible via node.keywords except that "keywords" also contains other names not just markers - probably not so bad, though.

As to the original posters question we should decide if we want to support nested classes at all - i haven't seen them used until this issue was created.

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


unless a non-anonymous user makes a case for supported nested classes with markers, i am considering it as wont-fix.

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
@DanCardin
Copy link

I realize this is rather old, but my usecase is thus:

test_filename.py

class TestClassName1:
    class TestMethodName1:
        def test_method_validation1(self):
            pass
        def test_method_validation2(self):
            pass

I could certainly make either the methods flat, or the classes flat but this was my initial inclination towards a method of grouping the tests in a way that did not repeat the prefix of the class under test or the class method under test for each test name.

@RonnyPfannschmidt
Copy link
Member

therefore it is reopened, but unlikely to be fixed soon

@RonnyPfannschmidt
Copy link
Member

@hpk42 i propose killing marker transfer entirely (since its broken) and inheriting marker elements from parents

@nicoddemus
Copy link
Member

(I didn't even knew nested classes were possible, heh).

i propose killing marker transfer entirely (since its broken)

Do you have an outline of how that would work? Obtain markers lazily from parents after collection?

@RonnyPfannschmidt
Copy link
Member

@nicoddemus i would prefer to get markers eagerly in order to avoid issues with nesting

@nicoddemus
Copy link
Member

By eagerly you mean right after collection completes?

Well I guess this is better discussed over a proposed implementation anyway. 😁

@nicoddemus
Copy link
Member

Created #2363, feel free to elaborate on that @RonnyPfannschmidt

@RonnyPfannschmidt RonnyPfannschmidt added the topic: marks related to marks, either the general marks or builtin label May 13, 2017
@RonnyPfannschmidt RonnyPfannschmidt moved this from todo to triage in resolve the mark fallout Jun 23, 2017
@RonnyPfannschmidt RonnyPfannschmidt moved this from triage to todo in resolve the mark fallout Jun 23, 2017
@RonnyPfannschmidt RonnyPfannschmidt moved this from todo to in progress in resolve the mark fallout Mar 27, 2018
@RonnyPfannschmidt RonnyPfannschmidt moved this from in progress to done in resolve the mark fallout Apr 10, 2018
@RonnyPfannschmidt
Copy link
Member

fixed by #3317

@edchelstephens
Copy link

Hi, is this solved?

@edchelstephens
Copy link

Is this nested test working?
Does all the test methods gets to run?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: marks related to marks, either the general marks or builtin type: bug problem that needs to be addressed
Projects
No open projects
Development

No branches or pull requests

5 participants