()
| 389 | |
| 390 | |
| 391 | def 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 | |
| 430 | def test_language_errors(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…