pytest-cmake icon indicating copy to clipboard operation
pytest-cmake copied to clipboard

Add properties to each test. List of tests

Open pprettysimpple opened this issue 1 year ago • 1 comments

Is there a way to add custom property (for example LABELS or WORKING_DIRECTORY) to each of the tests, added by pytest_discover_tests? Looks like my tests want to be launched in the specific directory + I want to separate long-running python from gtests of my project with a labels. The ability to hack-into and get the list of all tests might be really helpful, until every feature is supported natively with this function. Thanks!

pprettysimpple avatar Jul 05 '24 21:07 pprettysimpple

@pprettysimpple Apologies for the delayed response. Currently, you can set a WORKING_DIRECTORY or a custom ENVIRONMENT as an option (see API Reference), but custom properties are not available yet.

I'm working on it as part of this PR: https://github.com/python-cmake/pytest-cmake/pull/46

You should be able to add custom PROPERTIES as follows:

pytest_discover_tests(
    PythonTest
    ...
    PROPERTIES
        TIMEOUT 120
        LABELS "unit_tests;fast_tests"
)

Please let me know if this meets your requirements!

buddly27 avatar Oct 13 '24 03:10 buddly27

Custom properties were added as part of v0.11.0, so I'm closing this ticket for now. Please re-open it if needed.

buddly27 avatar Oct 16 '24 04:10 buddly27

thank you, I think it fits our use case. I will try it out in a few days

pprettysimpple avatar Oct 16 '24 16:10 pprettysimpple