MCPcopy
hub / github.com/docopt/docopt / test_basic_pattern_matching

Function test_basic_pattern_matching

test_docopt.py:268–284  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

266
267
268def test_basic_pattern_matching():
269 # ( -a N [ -x Z ] )
270 pattern = Required(Option('-a'), Argument('N'),
271 Optional(Option('-x'), Argument('Z')))
272 # -a N
273 assert pattern.match([Option('-a'), Argument(None, 9)]) == \
274 (True, [], [Option('-a'), Argument('N', 9)])
275 # -a -x N Z
276 assert pattern.match([Option('-a'), Option('-x'),
277 Argument(None, 9), Argument(None, 5)]) == \
278 (True, [], [Option('-a'), Argument('N', 9),
279 Option('-x'), Argument('Z', 5)])
280 # -x N Z # BZZ!
281 assert pattern.match([Option('-x'),
282 Argument(None, 9),
283 Argument(None, 5)]) == \
284 (False, [Option('-x'), Argument(None, 9), Argument(None, 5)], [])
285
286
287def test_pattern_either():

Callers

nothing calls this directly

Calls 5

matchMethod · 0.95
RequiredClass · 0.90
OptionClass · 0.90
ArgumentClass · 0.90
OptionalClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…