python-cmake / pytest-cmake

Pytest module for CMake
https://python-cmake.github.io/pytest-cmake/
MIT License
25 stars 0 forks source link

Impossible to trim test prefix when using class #20

Closed buddly27 closed 3 months ago

buddly27 commented 6 months ago

When a test is embedded within a class, the TRIM_FROM_NAME option from the "pytest_discover_tests" function applies to the class name instead of the method name.

class TestWorld:
    def test_greet(self):                                                                                                                                                                  
        """Greet the world."""
        assert example.greet() == "hello, world"
test 1
    Start 1: PythonTest.TestWorld.test_greet

We should create a TRIM_FROM_CLASS_NAME function to trim class names and fix the existing TRIM_FROM_NAME option to make it work with methods for consistency.