diff options
author | Henrique <typoon@gmail.com> | 2019-11-12 23:16:52 -0500 |
---|---|---|
committer | Henrique <typoon@gmail.com> | 2019-11-12 23:16:52 -0500 |
commit | d90262ad35b25a7a4ec0e01a2dd4d4c813729030 (patch) | |
tree | 9451d38e59239069a167fb38db0bd745b407d27f | |
parent | eee4b24e98b76b1eb33804d21264c5117a5c913c (diff) | |
download | mitmproxy-d90262ad35b25a7a4ec0e01a2dd4d4c813729030.tar.gz mitmproxy-d90262ad35b25a7a4ec0e01a2dd4d4c813729030.tar.bz2 mitmproxy-d90262ad35b25a7a4ec0e01a2dd4d4c813729030.zip |
Getting 100% coverage in the lexer
-rw-r--r-- | mitmproxy/lexer.py | 3 | ||||
-rw-r--r-- | test/mitmproxy/test_lexer.py | 14 |
2 files changed, 14 insertions, 3 deletions
diff --git a/mitmproxy/lexer.py b/mitmproxy/lexer.py index a7024ca2..f123a838 100644 --- a/mitmproxy/lexer.py +++ b/mitmproxy/lexer.py @@ -90,9 +90,6 @@ class Lexer: acc += ch else: acc += ch - else: - print("This shouldn't have happened") - exit(-1) self._token = acc 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) + + |