Skip to content

Add a condition keyword argument to thread_unsafe marker #190

Description

@ngoldbaum

Right now it's not straightforward to conditionally mark a test as thread-unsafe.

I'm working on a bug in CFFI that only manifests on MacOS. In order to express this, I have to write this right now:

@(pytest.mark.thread_unsafe(reason="unsafe on MacOS")
  if sys.platform == "darwin" else lambda f: f)
def test_thread_unsafe_on_mac():
    ...

It would be a lot nicer if we could do:

@pytest.mark.thread_unsafe(reason="unsafe on MacOS", condition=sys.platform == "darwin")
def test_thread_unsafe_on_mac():
    ...

Here condition behaves identically to the condition argument for pytest.mark.skipif: https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions