Skip to content

Commit

Permalink
Merge test_example.py into test_docopt.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
keleshev committed Jun 3, 2012
1 parent ff39ea3 commit f35a6a9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 44 deletions.
47 changes: 39 additions & 8 deletions test_docopt.py
Expand Up @@ -50,14 +50,6 @@ def test_option_name():
assert Option(None, '--help').name == '--help'


def test_docopt():
doc = '''Usage: prog [-v] A
-v Be verbose.'''
assert docopt(doc, 'arg') == {'-v': False, 'A': 'arg'}
assert docopt(doc, '-v arg') == {'-v': True, 'A': 'arg'}


def test_any_options():
doc = '''Usage: prog [options] A
Expand Down Expand Up @@ -408,3 +400,42 @@ def test_allow_double_underscore_in_pattern():

def test_allow_empty_pattern():
docopt('usage: prog', '') == {}


def test_docopt():
doc = '''Usage: prog [-v] A
-v Be verbose.'''
assert docopt(doc, 'arg') == {'-v': False, 'A': 'arg'}
assert docopt(doc, '-v arg') == {'-v': True, 'A': 'arg'}

doc = """Usage: prog [-vqr] [FILE]
prog INPUT OUTPUT
prog --help
Options:
-v print status messages
-q report only file names
-r show all occurrences of the same error
--help
"""
a = docopt(doc, '-v file.py')
assert a == {'-v': True, '-q': False, '-r': False, '--help': False,
'FILE': 'file.py', 'INPUT': None, 'OUTPUT': None}

a = docopt(doc, '-v')
assert a == {'-v': True, '-q': False, '-r': False, '--help': False,
'FILE': None, 'INPUT': None, 'OUTPUT': None}

with raises(DocoptExit): # does not match
docopt(doc, '-v input.py output.py')

with raises(DocoptExit):
docopt(doc, '--fake')

with raises(SystemExit):
docopt(doc, '--hel')

#with raises(SystemExit):
# docopt(doc, 'help') XXX Maybe help command?
36 changes: 0 additions & 36 deletions test_example.py

This file was deleted.

0 comments on commit f35a6a9

Please sign in to comment.