Skip to content

Instantly share code, notes, and snippets.

@jugmac00
Created February 13, 2020 06:48
Show Gist options
  • Save jugmac00/f9225fc7db0f502ccf8c1bd32eafc3ed to your computer and use it in GitHub Desktop.
Save jugmac00/f9225fc7db0f502ccf8c1bd32eafc3ed to your computer and use it in GitHub Desktop.
# 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