The title may be very vague, I did not know how to put the problem, so please excuse me for this.
I have a python file, say module.py
class myClass(obj):
"""
class Description
"""
def myMethod(args):
"""
method Description
"""
# method definition
I have one xml file, say module_result.xml
<testsuite errors="0" failures="0" name="module.myClass-20161215114804" skipped="0" tests="1" time="0.000">
<testcase classname="module.myClass" name="myMethod" time="0.000"/>
<system-out>
something
</system-out>
</testsuite>
I have another python file, test.py from where I have to use module_result.xml to parse module.py What I am doing in test.py (by giving hard coded path) is:
getdoc(module.myClass.myMethod)
I have to make this generic by reading names from xml, and those names are of type string
The argument type for getdoc() is object type, I am getting this error while using getddoc() with string:
str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.
working code in test.py:
import module
getdoc(module.myClass.myMethod)
But, this is hard coded, which is not acceptable in my case
I am extracting module/myClass/myMethod names from xml file
Lets say I got those names in variable by some logic as:
string_variable = "module.myClass.myMethod"
and I now want to do this:
getdoc(string_variable)
after doing this I am getting above mentioned error.
What can I do to convert string to object type?