Skip to content

Marks vs tags #4081

Closed
Closed

Description

@Sup3rGeo

Hi guys,

I am working in the allure-pytest plugin, and I think that pytest.mark.xxx is actually dealing with two different concepts.

One of them being the concept of tags, which are basically simple labels we are placing on the test, the goal being to use it later on to classify/select based on this. That is the case for pytest.mark.something, without any explicit call.

The other one is more implementation related, where marks are just some sort of attribute attached to a specific test (or derived from classes to tests) that pytest uses to implement some custom logic. In this category I would include skip, skipif, parametrize, use_fixture and others.

Correct if I am wrong, but we would never use pytest -m in any marks that are calls (second category)?

I would like to clarify this not to ask for any changes in pytest, but to know if it is correct to consider as "tags" in the report only the first category ("dumb" marks).

Thanks!

Activity

  1. added
    type: question
    topic: marks
    on Oct 4, 2018
  2. RonnyPfannschmidt commented on Oct 4, 2018

    @RonnyPfannschmidt
    Member

    @Sup3rGeo marks are Frankenstein monsters that started as somefunction.__dict__.update - and then evolved towards supporting arbitrary arguments

    recently we did a intense cleanup, so now all marks are actual named markers with potentially empty argument set, but we still provide some old api

    the marker expressions pretend all mark names are "tags"

    so pytest -m will use any marker, no matter whether it had arguments or not

  3. laurentbristiel commented on Oct 5, 2018

    @laurentbristiel

    This terminology of "marker" is one of the few thing that I found a bit confusing at first. I was expecting the word "tag" to be used. And in SO, people are writing things like "In pytest you can mark a test case with a tag"... But well, I guess you can live with that :-)

  4. RonnyPfannschmidt commented on Oct 5, 2018

    @RonnyPfannschmidt
    Member

    @laurentbristiel for all means and purposes - the markers where never "tags"

  5. nicoddemus commented on Oct 8, 2018

    @nicoddemus
    Member

    @Sup3rGeo can we close this?

  6. Sup3rGeo commented on Oct 9, 2018

    @Sup3rGeo
    MemberAuthor

    I would just like hear if someone is using pytest -m for markers other than the no-args ones (pytest.mark.xxx).

    Also, is pytest.mark.marker(param1=arg1, param2=arg2 ...) is still supported? What would be a use case for it? We have it on allure-pytest so I don't know if it is safe to remove support for it.

    @nicoddemus if no one says anything in a few days then we can close it.

  7. RonnyPfannschmidt commented on Oct 9, 2018

    @RonnyPfannschmidt
    Member

    @Sup3rGeo -m acts on all markers - but can only "attest" to existence

  8. Sup3rGeo commented on Oct 9, 2018

    @Sup3rGeo
    MemberAuthor

    @RonnyPfannschmidt I understood that (and nice to learn that it is checking for existence only), but just would like to know if people were really using pytest -m skip/use_fixtures/xfail or something like that in day-to-day usage.

    Because I feel it would make sense in terms of user experience that parametrize, xfail, an others not be marks. And leave marks only for the sole purpose of being selectable by -m.
    The consequence would be of course you cannot really select with -m for parametrize and xfail.

    @pytest.xfail()
    def function1():
        pass
    
    @pytest.parametrize( )
    def function2():
        pass
    
  9. RonnyPfannschmidt commented on Oct 9, 2018

    @RonnyPfannschmidt
    Member

    @Sup3rGeo i would expect not at all - but as is - parameterize, xfail and co are marks

    marks in general are designed and layered in a very sloppy foggy way due their history - its pretty much an completely unfixable issue by now

  10. nicoddemus commented on Oct 9, 2018

    @nicoddemus
    Member

    if people were really using pytest -m skip/use_fixtures/xfail or something like that in day-to-day usage.

    Oh I see. Well in my experience people use -m for marks which don't accept parameters, FWIW. 👍

  11. Sup3rGeo commented on Oct 10, 2018

    @Sup3rGeo
    MemberAuthor

    So closing this one given all the information here, thank you very much guys!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: markstype: question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions