Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100160 > unrolled thread
| Started by | Vincent Davis <vincent@vincentdavis.net> |
|---|---|
| First post | 2015-12-08 07:31 -0700 |
| Last post | 2015-12-08 07:31 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: manually build a unittest/doctest object. Vincent Davis <vincent@vincentdavis.net> - 2015-12-08 07:31 -0700
| From | Vincent Davis <vincent@vincentdavis.net> |
|---|---|
| Date | 2015-12-08 07:31 -0700 |
| Subject | Re: manually build a unittest/doctest object. |
| Message-ID | <mailman.68.1449585108.12405.python-list@python.org> |
On Tue, Dec 8, 2015 at 2:06 AM, Peter Otten <__peter__@web.de> wrote:
> >>> import doctest
> >>> example = doctest.Example(
> ... "print('hello world')\n",
> ... want="hello world\n")
> >>> test = doctest.DocTest([example], {}, None, None, None, None)
> >>> runner = doctest.DocTestRunner(verbose=True)
> >>> runner.run(test)
> Trying:
> print('hello world')
> Expecting:
> hello world
> ok
> TestResults(failed=0, attempted=1)
>
​and now how to do a multi line statement​.
>>> import doctest
>>> example =
doctest.Example("print('hello')\nprint('world')",want="hello\nworld")
>>> test = doctest.DocTest([example], {}, None, None, None, None)
>>> runner = doctest.DocTestRunner(verbose=True)
>>> runner.run(test)
Trying:
print('hello')
print('world')
Expecting:
hello
world
**********************************************************************
Line 1, in None
Failed example:
print('hello')
print('world')
Exception raised:
Traceback (most recent call last):
File "/Users/vincentdavis/anaconda/envs/py35/lib/python3.5/doctest.py",
line 1320, in __run
compileflags, 1), test.globs)
File "<doctest None[0]>", line 1
print('hello')
^
SyntaxError: multiple statements found while compiling a single statement
Vincent Davis
Back to top | Article view | comp.lang.python
csiph-web