Skip to content

Commit 5e4932b

Browse files
Added test for open_guess_encoding
1 parent 795769e commit 5e4932b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/unit/test_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from repo2docker import utils
77
import pytest
88
import subprocess
9+
import tempfile
910

1011

1112
def test_capture_cmd_no_capture_success():
@@ -112,6 +113,14 @@ def test_normalize_doi():
112113
assert utils.normalize_doi("http://dx.doi.org/10.1234/jshd123") == "10.1234/jshd123"
113114

114115

116+
def test_open_guess_encoding():
117+
data = "Rică nu știa să zică râu, rățușcă, rămurică."
118+
with tempfile.NamedTemporaryFile(mode='wb') as test_file:
119+
test_file.write(str.encode(data, "utf-16"))
120+
test_file.seek(0)
121+
with utils.open_guess_encoding(test_file.name) as fd:
122+
assert fd.read() == data
123+
115124
@pytest.mark.parametrize(
116125
"req, is_local",
117126
[

0 commit comments

Comments
 (0)