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 · 11 comments

Comments

Projects
4 participants
@pytestbot

pytestbot commented Oct 5, 2012

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

This comment has been minimized.

pytestbot commented Nov 5, 2012

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

This comment has been minimized.

pytestbot commented Nov 6, 2012

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

This comment has been minimized.

pytestbot commented Sep 5, 2013

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 label Jun 15, 2015

@pytestbot pytestbot closed this Jun 15, 2015

@DanCardin

This comment has been minimized.

DanCardin commented Apr 10, 2017

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

This comment has been minimized.

Member

RonnyPfannschmidt commented Apr 10, 2017

therefore it is reopened, but unlikely to be fixed soon

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented Apr 10, 2017

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

@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Apr 12, 2017

(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

This comment has been minimized.

Member

RonnyPfannschmidt commented Apr 12, 2017

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

@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Apr 12, 2017

By eagerly you mean right after collection completes?

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

@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Apr 12, 2017

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

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented Apr 10, 2018

fixed by #3317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment