Skip to content

Skipping a test in Pytest with skip decorator does not reflect the same in CTest execution #55

@AmeyaVS

Description

@AmeyaVS

I had marked a test as skip with the skip decorator available in Pytest refer: https://docs.pytest.org/en/stable/how-to/skipping.html#skipping-test-functions

# test_example.py
import pytest
# Test currently broken
@pytest.mark.skip(reason="Bug: Failing due to config changes")
def test_some_random_feature():
    # ...
    pass

While running the above snippet example with CTest:

ctest

I am observing the test as being passed with CTest:

    Start 1: test_example.test_some_random_feature
1/1 Test #1: test_example.test_some_random_feature ......................   Passed    0.11 sec

Adding the following PROPERTY in pytest_discover_tests seems to be handling it:

pytest_discover_tests(
    test_example
    DEPENDS test_example.py
    PROPERTIES
        SKIP_REGULAR_EXPRESSION "SKIPP;skipp"
)

Output:

    Start 1: test_example.test_some_random_feature
1/1 Test #1: test_example.test_some_random_feature ......................***Skipped   0.12 sec

A documentation/unit-test update would help with this feature tracking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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