MCPcopy
hub / github.com/docopt/docopt / test_docopt

Function test_docopt

test_docopt.py:391–427  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

389
390
391def test_docopt():
392 doc = '''Usage: prog [-v] A
393
394 -v Be verbose.'''
395 assert docopt(doc, 'arg') == {'-v': False, 'A': 'arg'}
396 assert docopt(doc, '-v arg') == {'-v': True, 'A': 'arg'}
397
398 doc = """Usage: prog [-vqr] [FILE]
399 prog INPUT OUTPUT
400 prog --help
401
402 Options:
403 -v print status messages
404 -q report only file names
405 -r show all occurrences of the same error
406 --help
407
408 """
409 a = docopt(doc, '-v file.py')
410 assert a == {'-v': True, '-q': False, '-r': False, '--help': False,
411 'FILE': 'file.py', 'INPUT': None, 'OUTPUT': None}
412
413 a = docopt(doc, '-v')
414 assert a == {'-v': True, '-q': False, '-r': False, '--help': False,
415 'FILE': None, 'INPUT': None, 'OUTPUT': None}
416
417 with raises(DocoptExit): # does not match
418 docopt(doc, '-v input.py output.py')
419
420 with raises(DocoptExit):
421 docopt(doc, '--fake')
422
423 with raises(SystemExit):
424 docopt(doc, '--hel')
425
426 #with raises(SystemExit):
427 # docopt(doc, 'help') XXX Maybe help command?
428
429
430def test_language_errors():

Callers

nothing calls this directly

Calls 1

docoptFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…