Created
February 13, 2020 06:48
-
-
Save jugmac00/f9225fc7db0f502ccf8c1bd32eafc3ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding=utf-8 | |
| import pytest | |
| from Products.Libs.string_utils import try_to_convert_list_to_windows_1252_text | |
| @pytest.mark.parametrize("list_, encoding", [ | |
| (["abc", "d€f"], "Windows-1252"), | |
| (["我犀角鳥啄忘我", "我犀角鳥啄忘我"], "UTF-16") | |
| ]) | |
| def test_try_to_convert_list_to_windows_1252_text(list_, encoding): | |
| encoded_text = try_to_convert_list_to_windows_1252_text(list_) | |
| assert chardet.detect(encoded_text)["encoding"] == encoding | |
| # This code runs on Python 2.7 on my Ubuntu 18.04, on staging (Nixos), | |
| # on production (Nixos), on one Travis pipeline, but fails on another | |
| # Travis pipeline - then with a UnicodeDecodeError | |
| # Why had this code worked for months? | |
| # What possibly could have changed (possibly in the setting/os) so | |
| # that the tests breaks now? | |
| # Note: There is no `u` prefix used!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment