I was trying to get the docstrings of all the test functions from a fixture defined in conftest.py, as shown in the code below, so that they can be analyzed for purposes.
But, from here how can I access the __doc__
attribute of that function when the function is only available as a string (request.node.name
) !?
Is there a way to read docstrings through request
OR from other default pytest fixtures !?
Contents of conftest.py
1 import pytest
2
3 @pytest.fixture(scope='function', autouse=True)
4 def publish_to_pubsub(request):
5 print("\n\nSTARTED Test '{}'".format(request.node.name))
6 test_name = request.node.name
// Here - need to get the docstring of this function .
7
9 def fin():
12 print("COMPLETED Test '{}'\n".format(request.node.name))
13
14 request.addfinalizer(fin)