| # Copyright (c) 2013-2014 Google, Inc. |
| # Copyright (c) 2013-2014 LOGILAB S.A. (Paris, FRANCE) <[email protected]> |
| # Copyright (c) 2014 Arun Persaud <[email protected]> |
| # Copyright (c) 2015-2018, 2020 Claudiu Popa <[email protected]> |
| # Copyright (c) 2015 Aru Sahni <[email protected]> |
| # Copyright (c) 2015 Ionel Cristian Maries <[email protected]> |
| # Copyright (c) 2016 Derek Gustafson <[email protected]> |
| # Copyright (c) 2016 Glenn Matthews <[email protected]> |
| # Copyright (c) 2017-2019, 2021 Pierre Sassoulas <[email protected]> |
| # Copyright (c) 2017-2018, 2020 Anthony Sottile <[email protected]> |
| # Copyright (c) 2017 ttenhoeve-aa <[email protected]> |
| # Copyright (c) 2017 Łukasz Rogalski <[email protected]> |
| # Copyright (c) 2019 Ashley Whetter <[email protected]> |
| # Copyright (c) 2020 Peter Kolbus <[email protected]> |
| # Copyright (c) 2020 hippo91 <[email protected]> |
| # Copyright (c) 2021 Marc Mueller <[email protected]> |
| |
| # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE |
| |
| import io |
| |
| from pylint.utils import utils |
| |
| |
| def test_decoding_stream_unknown_encoding(): |
| """decoding_stream should fall back to *some* decoding when given an |
| unknown encoding. |
| """ |
| binary_io = io.BytesIO(b"foo\nbar") |
| stream = utils.decoding_stream(binary_io, "garbage-encoding") |
| # should still act like a StreamReader |
| ret = stream.readlines() |
| assert ret == ["foo\n", "bar"] |
| |
| |
| def test_decoding_stream_known_encoding(): |
| binary_io = io.BytesIO("€".encode("cp1252")) |
| stream = utils.decoding_stream(binary_io, "cp1252") |
| assert stream.read() == "€" |