Permalink
Browse files

Make docopt docstring doctestable

Doctest is run on Python 2.7 only, since doctests are
usually not very portable, plus we want to test
documentation, not code.
  • Loading branch information...
keleshev committed Mar 7, 2013
1 parent bebc240 commit 53d0d85f6461ef8b8e1980415e9d5653805f1424
Showing with 14 additions and 9 deletions.
  1. +9 −9 docopt.py
  2. +5 −0 tox.ini
View
@@ -526,15 +526,15 @@ def docopt(doc, argv=None, help=True, version=None, options_first=False):
-------
>>> from docopt import docopt
>>> doc = '''
- Usage:
- my_program tcp <host> <port> [--timeout=<seconds>]
- my_program serial <port> [--baud=<n>] [--timeout=<seconds>]
- my_program (-h | --help | --version)
-
- Options:
- -h, --help Show this screen and exit.
- --baud=<n> Baudrate [default: 9600]
- '''
+ ... Usage:
+ ... my_program tcp <host> <port> [--timeout=<seconds>]
+ ... my_program serial <port> [--baud=<n>] [--timeout=<seconds>]
+ ... my_program (-h | --help | --version)
+ ...
+ ... Options:
+ ... -h, --help Show this screen and exit.
+ ... --baud=<n> Baudrate [default: 9600]
+ ... '''
>>> argv = ['tcp', '127.0.0.1', '80', '--timeout', '30']
>>> docopt(doc, argv)
{'--baud': '9600',
View
@@ -10,6 +10,11 @@ envlist = py25, py26, py27, py32, py33, pypy
commands = py.test
deps = pytest
+[testenv:py27]
+commands = py.test
+ py.test --doctest-modules docopt.py
+deps = pytest
+
[testenv:py25]
commands = py.test
deps = pytest

0 comments on commit 53d0d85

Please sign in to comment.