I'm trying to read python code (specifically, unit tests) as structured objects.
For example.
class ProjectA(unittest.TestCase):
def testB(self):
"""
hello world B
"""
assert False
def testA(self):
"""
hello world
"""
assert False
I will like to read this code file into an object a dict like this:
{
'classes': [{'ProjectA': [__init__, testA, testB]}]
}
For which I can read testA's via testA['docstring'].
Basically, I'd like to get the structure of python code into an object for which I can parse.
What will something like this be called? (So I can read up about it)
Thank you!
import <py_file> ; help(<py_file>)will give you automatically generated documentation for that file. It isn't the dict you are looking for but if you just want something to quickly see all the docstrings that is probably the way to go.