aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHenrique <typoon@gmail.com>2019-11-12 23:16:52 -0500
committerHenrique <typoon@gmail.com>2019-11-12 23:16:52 -0500
commitd90262ad35b25a7a4ec0e01a2dd4d4c813729030 (patch)
tree9451d38e59239069a167fb38db0bd745b407d27f /test
parenteee4b24e98b76b1eb33804d21264c5117a5c913c (diff)
downloadmitmproxy-d90262ad35b25a7a4ec0e01a2dd4d4c813729030.tar.gz
mitmproxy-d90262ad35b25a7a4ec0e01a2dd4d4c813729030.tar.bz2
mitmproxy-d90262ad35b25a7a4ec0e01a2dd4d4c813729030.zip
Getting 100% coverage in the lexer
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_lexer.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/mitmproxy/test_lexer.py b/test/mitmproxy/test_lexer.py
index ae706407..a1898620 100644
--- a/test/mitmproxy/test_lexer.py
+++ b/test/mitmproxy/test_lexer.py
@@ -1,5 +1,6 @@
from mitmproxy import lexer
import pytest
+import io
class TestScripts:
@@ -47,6 +48,10 @@ class TestScripts:
"text": '\n\n\rHello\n World With Spaces\n\n',
"result": ['Hello', 'World', 'With', 'Spaces']
},
+ {
+ "text": r'\" Escaping characters without reason',
+ "result": ['\\"', 'Escaping', 'characters', 'without', 'reason']
+ },
]
for t in cases:
@@ -61,3 +66,12 @@ class TestScripts:
lex = lexer.Lexer(text)
with pytest.raises(ValueError, match="No closing quotation"):
assert list(lex)
+
+ def test_stringio_text(self):
+ text = io.StringIO(r'Increase test coverage')
+ lex = lexer.Lexer(text)
+ tokens = list(lex)
+ result = ['Increase', 'test', 'coverage']
+ assert(tokens == result)
+
+