summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthäus G. Chajdas <dev@anteru.net>2020-03-01 15:21:25 +0100
committerMatthäus G. Chajdas <dev@anteru.net>2020-03-01 15:50:52 +0100
commit11ea92ad40218608a7e3e060b7bf290cb70a3904 (patch)
tree132dca6365f9bbbba382578a1bb2df81a78ca956 /tests
parent15b31a090f4e415c6d1bbd8a704cc89b34802449 (diff)
downloadpygments-git-11ea92ad40218608a7e3e060b7bf290cb70a3904.tar.gz
Fix tests on Windows.
This fixes three test failures on Windows: * Two due to incorrect handling of : (on Windows, multiple : can be part of a path.) * One due to newline differences
Diffstat (limited to 'tests')
-rw-r--r--tests/test_basic_api.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index 7f71791e..81ca3c30 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -268,8 +268,11 @@ class TestFilters:
for x, args in filters_args:
lx = lexers.PythonLexer()
lx.add_filter(x, **args)
- with open(TESTFILE, 'rb') as fp:
- text = fp.read().decode('utf-8')
+ # We don't read as binary and decode, but instead read as text, as
+ # we need consistent line endings. Otherwise we'll get \r\n on
+ # Windows
+ with open(TESTFILE, 'r', encoding='utf-8') as fp:
+ text = fp.read()
tokens = list(lx.get_tokens(text))
assert all(isinstance(t[1], str) for t in tokens), \
'%s filter did not return Unicode' % x