Closed Gochkin closed 2 weeks ago
A hard no for including this in core
It's using tracing to hack on collection and it is completely unclear how to integrate it with fixtures and parameterization
Python has no good Way to manage controlled namespaces beside classes
Description
I would like to have the ability to arbitrarily nest test functions in the same manner as facilitated by the pytest-describe plugin. While we can currently nest test functions using nested test classes, these nested classes impose limitations when accessing fields and properties from outer classes. My goal is to organize and group tests to mirror the structure of the code being tested. Specifically, I want a test class for each class (including nested and inherited classes) and a group (or multiple groups) of test functions for each function. Although
pytest-describe
provides this functionality, I believe it should be an integral part of pytest's general test discovery, organizational grouping, and structure.What's the Problem This Feature Will Solve?
If implemented, this feature will allow:
pytest-describe
plugin.)@given
decorator) between nested classes using fixtures.Describe the Solution You'd Like
I would like the ability to arbitrarily nest test functions. pytest should be able to:
Alternative Solutions
I could use the pytest-describe plugin, but I believe this functionality should be part of the core
pytest
. I also found thepytest-relaxed
plugin, which helps achieve similar functionality with inner classes by automatically passing all members of the outer class to the inner class. However, it seems to be incompatible withhypothesis
.