<s>
doctest	B-Application
is	O
a	O
module	O
included	O
in	O
the	O
Python	B-Language
programming	I-Language
language	I-Language
's	O
standard	O
library	O
that	O
allows	O
the	O
easy	O
generation	O
of	O
tests	O
based	O
on	O
output	O
from	O
the	O
standard	O
Python	B-Language
interpreter	O
shell	O
,	O
cut	O
and	O
pasted	O
into	O
docstrings	B-Language
.	O
</s>
<s>
Doctest	B-Application
makes	O
innovative	O
use	O
of	O
the	O
following	O
Python	B-Language
capabilities	O
:	O
</s>
<s>
When	O
using	O
the	O
Python	B-Language
shell	O
,	O
the	O
primary	O
prompt	O
:	O
>>>	O
,	O
is	O
followed	O
by	O
new	O
commands	O
.	O
</s>
<s>
The	O
doctest	B-Application
module	O
looks	O
for	O
such	O
sequences	O
of	O
prompts	O
in	O
a	O
docstring	B-Language
,	O
re-executes	O
the	O
extracted	O
command	O
and	O
checks	O
the	O
output	O
against	O
the	O
output	O
of	O
the	O
command	O
given	O
in	O
the	O
docstrings	B-Language
test	O
example	O
.	O
</s>
<s>
The	O
default	O
action	O
when	O
running	O
doctests	B-Application
is	O
for	O
no	O
output	O
to	O
be	O
shown	O
when	O
tests	O
pass	O
.	O
</s>
<s>
This	O
can	O
be	O
modified	O
by	O
options	O
to	O
the	O
doctest	B-Application
runner	O
.	O
</s>
<s>
In	O
addition	O
,	O
doctest	B-Application
has	O
been	O
integrated	O
with	O
the	O
Python	B-Language
unit	O
test	O
module	O
allowing	O
doctests	B-Application
to	O
be	O
run	O
as	O
standard	O
unittest	O
testcases	O
.	O
</s>
<s>
Although	O
doctest	B-Application
does	O
not	O
allow	O
a	O
Python	B-Language
program	I-Language
to	O
be	O
embedded	O
in	O
narrative	O
text	O
,	O
it	O
does	O
allow	O
for	O
verifiable	O
examples	O
to	O
be	O
embedded	O
in	O
docstrings	B-Language
,	O
where	O
the	O
docstrings	B-Language
can	O
contain	O
other	O
text	O
.	O
</s>
<s>
Docstrings	B-Language
can	O
in	O
turn	O
be	O
extracted	O
from	O
program	O
files	O
to	O
generate	O
documentation	O
in	O
other	O
formats	O
such	O
as	O
HTML	O
or	O
PDF	O
.	O
</s>
<s>
Doctests	B-Application
are	O
well	O
suited	O
to	O
provide	O
an	O
introduction	O
to	O
a	O
library	O
by	O
demonstrating	O
how	O
the	O
API	O
is	O
used	O
.	O
</s>
<s>
On	O
the	O
basis	O
of	O
the	O
output	O
of	O
Python	B-Language
's	O
interactive	O
interpreter	O
,	O
text	O
can	O
be	O
mixed	O
with	O
tests	O
that	O
exercise	O
the	O
library	O
,	O
showing	O
expected	O
results	O
.	O
</s>
<s>
Example	O
one	O
shows	O
how	O
narrative	O
text	O
can	O
be	O
interspersed	O
with	O
testable	O
examples	O
in	O
a	O
docstring	B-Language
.	O
</s>
<s>
In	O
the	O
second	O
example	O
,	O
more	O
features	O
of	O
doctest	B-Application
are	O
shown	O
,	O
together	O
with	O
their	O
explanation	O
.	O
</s>
<s>
Example	O
three	O
is	O
set	O
up	O
to	O
run	O
all	O
doctests	B-Application
in	O
a	O
file	O
when	O
the	O
file	O
is	O
run	O
,	O
but	O
when	O
imported	O
as	O
a	O
module	O
,	O
the	O
tests	O
will	O
not	O
be	O
run	O
.	O
</s>
<s>
Both	O
the	O
EpyText	B-Protocol
format	O
of	O
Epydoc	B-Protocol
and	O
Docutils	O
 '	O
reStructuredText	B-Language
format	O
support	O
the	O
markup	O
of	O
doctest	B-Application
sections	O
within	O
docstrings	B-Language
.	O
</s>
<s>
In	O
C++	O
,	O
the	O
doctest	B-Application
framework	O
is	O
the	O
closest	O
possible	O
implementation	O
of	O
the	O
concept	O
-	O
tests	O
can	O
be	O
written	O
directly	O
in	O
the	O
production	O
code	O
with	O
minimal	O
overhead	O
and	O
the	O
option	O
to	O
strip	O
them	O
from	O
the	O
binary	O
.	O
</s>
<s>
The	O
ExUnit.DocTest	O
Elixir	B-Language
library	O
implements	O
functionality	O
similar	O
to	O
Doctest	B-Application
.	O
</s>
<s>
An	O
implementation	O
of	O
Doctest	B-Application
for	O
Haskell	B-Language
.	O
</s>
<s>
Writing	O
documentation	O
tests	O
in	O
Elm	B-Language
.	O
</s>
<s>
Writing	O
documentation	O
tests	O
in	O
Rust	B-Application
.	O
</s>
<s>
Writing	O
documentation	O
tests	O
in	O
Elixir	B-Language
.	O
</s>
<s>
byexample	O
supports	O
writing	O
doctests	B-Application
for	O
several	O
popular	O
programming	O
languages	O
(	O
e.g.	O
</s>
<s>
Python	B-Language
,	O
Ruby	O
,	O
Shell	O
,	O
JavaScript	O
,	O
C/C	O
++	O
,	O
Java	O
,	O
Go	O
,	O
Rust	B-Application
)	O
inside	O
Markdown	O
,	O
reStructuredText	B-Language
and	O
other	O
text	O
documents	O
.	O
</s>
