def test_basic_pattern_matching(): # ( -a N [ -x Z ] ) pattern = Required(Option("-a"), Argument("N"), NotRequired(Option("-x"), Argument("Z"))) # -a N assert pattern.match([Option("-a"), Argument(None, 9) ]) == (True, [], [Option("-a"), Argument("N", 9)]) # -a -x N Z assert pattern.match( [Option("-a"), Option("-x"), Argument(None, 9), Argument(None, 5)]) == ( True, [], [Option("-a"), Argument("N", 9), Option("-x"), Argument("Z", 5)], ) # -x N Z # BZZ! assert pattern.match([Option("-x"), Argument(None, 9), Argument(None, 5)]) == (False, [ Option("-x"), Argument(None, 9), Argument(None, 5) ], [])
def test_basic_pattern_matching(): # ( -a N [ -x Z ] ) pattern = Required(Option('-a'), Argument('N'), Optional(Option('-x'), Argument('Z'))) # -a N assert pattern.match([Option('-a'), Argument(None, 9)]) == \ (True, [], [Option('-a'), Argument('N', 9)]) # -a -x N Z assert pattern.match([Option('-a'), Option('-x'), Argument(None, 9), Argument(None, 5)]) == \ (True, [], [Option('-a'), Argument('N', 9), Option('-x'), Argument('Z', 5)]) # -x N Z # BZZ! assert pattern.match([Option('-x'), Argument(None, 9), Argument(None, 5)]) == \ (False, [Option('-x'), Argument(None, 9), Argument(None, 5)], [])
def test_basic_pattern_matching(): # ( -a N [ -x Z ] ) pattern = Required(Option("-a"), Argument("N"), Optional(Option("-x"), Argument("Z"))) # -a N assert pattern.match([Option("-a"), Argument(None, 9)]) == (True, [], [Option("-a"), Argument("N", 9)]) # -a -x N Z assert pattern.match([Option("-a"), Option("-x"), Argument(None, 9), Argument(None, 5)]) == ( True, [], [Option("-a"), Argument("N", 9), Option("-x"), Argument("Z", 5)], ) # -x N Z # BZZ! assert pattern.match([Option("-x"), Argument(None, 9), Argument(None, 5)]) == ( False, [Option("-x"), Argument(None, 9), Argument(None, 5)], [], )