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

A question on how marks work #3462

Closed
Drew-Ack opened this issue May 10, 2018 · 3 comments
Closed

A question on how marks work #3462

Drew-Ack opened this issue May 10, 2018 · 3 comments
Labels
type: question general question, might be closed after 2 weeks of inactivity

Comments

@Drew-Ack
Copy link

Drew-Ack commented May 10, 2018

This is somewhat related to #3446, I know you are all working on editing the way markers work

Im starting to use markers in my project and want to go over the functionality to make sure I am using them fully.

Heres the test code

test_Tags.py

@pytest.mark.a
def test_a():
    print("test_a ran")

@pytest.mark.b
def test_b():
    print("test_b ran")

@pytest.mark.c
def test_c():
    print("test_c ran")


@pytest.mark.a
@pytest.mark.b
def test_a_and_b():
    print("test_a_and_b ran")

If we try to "filter" on a single tag "c" then we get one test ran. Easy to understand.
Running: pytest test_Tags.py -m "c" -s
test_c ran .

If we try to filter on tag "a" which is on two tests, then tests with that mark run. Okay.
Running: pytest test_Tags.py -m "a" -s
test_a ran test_a_and_b ran

If we try to filter on tag "not a" which is on two tests, then tests without mark a are run. Got it
Running: pytest test_Tags.py -m "not a" -s
test_b ran test_c ran

So as far as marks are concerned, you can filter only on one and cant create a composite filter. Which would be nice possibly.
I can see why that'd be difficult because what if i say
pytest test_Tags.py -m "a not b" -s
Does test_a_and_b() get ran or not?

If there are some cool things i'm missing, that'd be great to know :)

@nicoddemus
Copy link
Member

Hi @Drew-Ack,

I can see why that'd be difficult because what if i say
pytest test_Tags.py -m "a not b" -s
Does test_a_and_b() get ran or not?

I suppose you can use -m "a and not b" or -m "a or not b"?

@nicoddemus nicoddemus added the type: question general question, might be closed after 2 weeks of inactivity label May 10, 2018
@Drew-Ack
Copy link
Author

Well its a good thing i checked. The documentation on marks using examples doesnt explictly go over that you can use and or or. There seems to be inly one example at the very bottom of the page.

Thank you for your assistance.

@nicoddemus
Copy link
Member

Thanks ... it seems your question has been resolved so I'm closing this for now. Feel free to followup with further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants