|
33 | 33 | from awscli.help import OperationHelpCommand |
34 | 34 | from awscli.paramfile import LOCAL_PREFIX_MAP, URIArgumentHandler |
35 | 35 | from awscli.testutils import BaseCLIDriverTest, mock, temporary_file, unittest |
| 36 | +from awscli.argparser import ArgTableArgParser |
36 | 37 |
|
37 | 38 |
|
38 | 39 | # These tests use real service types so that we can |
@@ -968,5 +969,39 @@ def test_json_value_decode_error(self): |
968 | 969 | unpack_cli_arg(self.p, value) |
969 | 970 |
|
970 | 971 |
|
| 972 | +class TestArgumentPercentEscaping(BaseArgProcessTest): |
| 973 | + def _test_percent_escaping(self, arg_type, arg_class, doc_string): |
| 974 | + argument = self.create_argument( |
| 975 | + { |
| 976 | + 'Test': { |
| 977 | + 'type': arg_type, |
| 978 | + 'documentation': doc_string, |
| 979 | + } |
| 980 | + } |
| 981 | + ) |
| 982 | + arg = arg_class( |
| 983 | + 'test-arg', |
| 984 | + argument.argument_model.members['Test'], |
| 985 | + mock.Mock(), |
| 986 | + mock.Mock(), |
| 987 | + is_required=False, |
| 988 | + ) |
| 989 | + arg_table = {arg.name: arg} |
| 990 | + parser = ArgTableArgParser(arg_table) |
| 991 | + help_output = parser.format_help() |
| 992 | + self.assertIn(doc_string, help_output) |
| 993 | + |
| 994 | + def test_cli_argument_escapes_percent(self): |
| 995 | + self._test_percent_escaping('string', CLIArgument, 'Symbols: % ^ & *') |
| 996 | + |
| 997 | + def test_boolean_argument_escapes_percent(self): |
| 998 | + self._test_percent_escaping('boolean', BooleanArgument, 'Symbols: % ^ & *') |
| 999 | + |
| 1000 | + def test_cli_argument_escapes_url_encoded_percent(self): |
| 1001 | + self._test_percent_escaping('string', CLIArgument, 'File: test%28file%29.png') |
| 1002 | + |
| 1003 | + def test_boolean_argument_escapes_url_encoded_percent(self): |
| 1004 | + self._test_percent_escaping('boolean', BooleanArgument, 'File: test%28file%29.png') |
| 1005 | + |
971 | 1006 | if __name__ == '__main__': |
972 | 1007 | unittest.main() |
0 commit comments