| 166 | |
| 167 | |
| 168 | def test_command_match(): |
| 169 | assert Command('c').match([Argument(None, 'c')]) == \ |
| 170 | (True, [], [Command('c', True)]) |
| 171 | assert Command('c').match([Option('-x')]) == (False, [Option('-x')], []) |
| 172 | assert Command('c').match([Option('-x'), |
| 173 | Option('-a'), |
| 174 | Argument(None, 'c')]) == \ |
| 175 | (True, [Option('-x'), Option('-a')], [Command('c', True)]) |
| 176 | assert Either(Command('add', False), Command('rm', False)).match( |
| 177 | [Argument(None, 'rm')]) == (True, [], [Command('rm', True)]) |
| 178 | |
| 179 | |
| 180 | def test_optional_match(): |