manually build a unittest/doctest object.

Vincent Davis vincent at vincentdavis.net
Mon Dec 7 22:30:19 EST 2015


If I have a string that is python code, for example
mycode = "print('hello world')"
myresult = "hello world"
How can a "manually" build a unittest (doctest) and test I get myresult

I have attempted to build a doctest but that is not working.
e = doctest.Example(source="print('hello world')/n", want="hello world\n")
t = doctest.DocTestRunner()
t.run(e)

Thanks
Vincent Davis



More information about the Python-list mailing list