|
16 | 16 | import signal |
17 | 17 | from unittest import mock |
18 | 18 |
|
19 | | -import yaml |
| 19 | +from ruamel.yaml import YAML |
20 | 20 | from botocore.exceptions import ClientError, NoCredentialsError, NoRegionError |
21 | 21 |
|
22 | 22 | from awscli.arguments import UnknownArgumentError |
@@ -463,6 +463,12 @@ def test_error_handler_without_parsed_globals_uses_default(self): |
463 | 463 |
|
464 | 464 |
|
465 | 465 | class TestNonModeledErrorStructuredFormatting: |
| 466 | + def setup_method(self): |
| 467 | + self.yaml = YAML(typ="safe", pure=True) |
| 468 | + |
| 469 | + def _load_yaml(self, content): |
| 470 | + return self.yaml.load(io.StringIO(content)) |
| 471 | + |
466 | 472 | def test_no_region_error_with_json_format(self): |
467 | 473 | session = FakeSession() |
468 | 474 | error_handler = construct_cli_error_handlers_chain(session) |
@@ -503,7 +509,7 @@ def test_no_credentials_error_with_yaml_format(self): |
503 | 509 |
|
504 | 510 | assert rc == CONFIGURATION_ERROR_RC |
505 | 511 | stderr_output = stderr.getvalue() |
506 | | - parsed_yaml = yaml.safe_load(stderr_output) |
| 512 | + parsed_yaml = self._load_yaml(stderr_output) |
507 | 513 | assert parsed_yaml['Code'] == 'NoCredentials' |
508 | 514 | assert ( |
509 | 515 | 'aws' in parsed_yaml['Message'] |
@@ -576,7 +582,7 @@ def test_param_validation_error_with_yaml_format(self): |
576 | 582 |
|
577 | 583 | assert rc == PARAM_VALIDATION_ERROR_RC |
578 | 584 | stderr_output = stderr.getvalue() |
579 | | - parsed_yaml = yaml.safe_load(stderr_output) |
| 585 | + parsed_yaml = self._load_yaml(stderr_output) |
580 | 586 | assert parsed_yaml['Code'] == 'ParamValidation' |
581 | 587 | assert 'Invalid parameter value' in parsed_yaml['Message'] |
582 | 588 |
|
|
0 commit comments