| 1 |
================================= |
| 2 |
Tests in example form - IPython |
| 3 |
================================= |
| 4 |
|
| 5 |
You can write text files with examples that use IPython prompts (as long as you |
| 6 |
use the nose ipython doctest plugin), but you can not mix and match prompt |
| 7 |
styles in a single file. That is, you either use all ``>>>`` prompts or all |
| 8 |
IPython-style prompts. Your test suite *can* have both types, you just need to |
| 9 |
put each type of example in a separate. Using IPython prompts, you can paste |
| 10 |
directly from your session:: |
| 11 |
|
| 12 |
In [5]: s="Hello World" |
| 13 |
|
| 14 |
In [6]: s.upper() |
| 15 |
Out[6]: 'HELLO WORLD' |
| 16 |
|
| 17 |
Another example:: |
| 18 |
|
| 19 |
In [8]: 1+3 |
| 20 |
Out[8]: 4 |
| 21 |
|
| 22 |
Just like in IPython docstrings, you can use all IPython syntax and features:: |
| 23 |
|
| 24 |
In [9]: !echo hello |
| 25 |
hello |
| 26 |
|
| 27 |
In [10]: a='hi' |
| 28 |
|
| 29 |
In [11]: !echo $a |
| 30 |
hi |