(self, env_vars)
| 127 | ], |
| 128 | ) |
| 129 | def test_encoding_override(self, env_vars): |
| 130 | response = {'TableNames': ['桌子']} |
| 131 | stdout_b = io.BytesIO() |
| 132 | stdout = io.TextIOWrapper(stdout_b, encoding="cp1252", newline='\n') |
| 133 | |
| 134 | formatter = StreamedYAMLFormatter(self.args) |
| 135 | with mock.patch.dict(os.environ, env_vars): |
| 136 | with contextlib.redirect_stdout(stdout): |
| 137 | assert 'cp1252' == sys.stdout.encoding |
| 138 | formatter('list-tables', response, sys.stdout) |
| 139 | # we expect the formatter to have changed the output stream |
| 140 | # encoding based on AWS_CLI_OUTPUT_ENCODING |
| 141 | assert 'UTF-8' == sys.stdout.encoding |
| 142 | stdout.flush() |
| 143 | |
| 144 | assert stdout_b.getvalue() == ('- TableNames:\n' ' - 桌子\n').encode() |
| 145 | |
| 146 | |
| 147 | class TestJSONFormatter: |
nothing calls this directly
no test coverage detected