File: skip_some.tex

package info (click to toggle)
pytest-doctestplus 1.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 352 kB
  • sloc: python: 2,004; makefile: 13; sh: 7
file content (91 lines) | stat: -rw-r--r-- 1,409 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
\documentclass{article}
\setlength{\parindent}{0cm}

\usepackage{listings}
\lstnewenvironment{python}[1][]{
\lstset{
language=python,
}}{}

\begin{document}

Some of the example code blocks in this file are perfectly valid and will pass
if they run. Some are not. The intent of this file is to test the directives
that are provided by the ``--doctest-text'' option to make sure that the bad
ones get skipped.

\section{Here's One That Works}

This code block should work just fine::

\begin{python}
>>> 1 + 1
2

\end{python}

This one should work just fine as well::

\begin{python}
>>> x = 5
>>> x
5

\end{python}

\section{Here's One That Doesn't}

This code won't run. So let's make sure that it gets skipped:

% doctest-skip::
\begin{python}
>>> y + z
42

\end{python}

This one doesn't work either:

% doctest-skip::
\begin{python}
>>> print(blue)
'blue'

\end{python}

\section{Good Imports}

There should be nothing wrong with this code, so we'll let it run:

\begin{python}
>>> import os
>>> os.path.curdir
'.'

\end{python}

Make sure the `doctest-requires` directive works for modules that are
available:

% doctest-requires:: sys
\begin{python}
>>> import sys

\end{python}


\section{Bad Imports}


I don't think this module exists, so we should make sure that this code doesn't
run:

% doctest-requires:: foobar
\begin{python}
>>> import foobar
>>> foobar.baz(42)
1

\end{python}

\end{document}