Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100132

manually build a unittest/doctest object.

From Vincent Davis <vincent@vincentdavis.net>
Newsgroups comp.lang.python
Subject manually build a unittest/doctest object.
Date 2015-12-07 20:30 -0700
Message-ID <mailman.47.1449545442.12405.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

manually build a unittest/doctest object. Vincent Davis <vincent@vincentdavis.net> - 2015-12-07 20:30 -0700
  Re: manually build a unittest/doctest object. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-12-08 16:56 +1100

csiph-web