summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2021-01-07 08:41:11 -0800
committerAnthony Sottile <asottile@umich.edu>2021-01-07 09:15:46 -0800
commit0bf8d2a88586b6a1490fd5eaa1d29e1ed16ea705 (patch)
tree17bfb71e42f3902cda825dcd64eb4c9903465951 /tests
parentff433b2e64e864e44ce0fbb9a0145fe7164db904 (diff)
downloadflake8-0bf8d2a88586b6a1490fd5eaa1d29e1ed16ea705.tar.gz
ensure crlf line endings of stdin are handled properly
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index c84a03b..4b89484 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -1,6 +1,8 @@
"""Tests for flake8's utils module."""
+import io
import logging
import os
+import sys
import mock
import pytest
@@ -304,3 +306,11 @@ def test_matches_filename_for_excluding_dotfiles():
logger = logging.Logger(__name__)
assert not utils.matches_filename('.', ('.*',), '', logger)
assert not utils.matches_filename('..', ('.*',), '', logger)
+
+
+@pytest.mark.xfail(sys.version_info < (3,), reason='py3+ only behaviour')
+def test_stdin_get_value_crlf():
+ """Ensure that stdin is normalized from crlf to lf."""
+ stdin = io.TextIOWrapper(io.BytesIO(b'1\r\n2\r\n'), 'UTF-8')
+ with mock.patch.object(sys, 'stdin', stdin):
+ assert utils.stdin_get_value.__wrapped__() == '1\n2\n'