MCPcopy
hub / github.com/aws/aws-cli / test_encoding_override

Method test_encoding_override

tests/unit/test_formatter.py:129–144  ·  view source on GitHub ↗
(self, env_vars)

Source from the content-addressed store, hash-verified

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
147class TestJSONFormatter:

Callers

nothing calls this directly

Calls 4

flushMethod · 0.45
getvalueMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected