Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de>
Branch: pyparser-improvements-2
Changeset: r94272:8b6d076bb5b7
Date: 2018-04-07 13:50 +0200
http://bitbucket.org/pypy/pypy/changeset/8b6d076bb5b7/

Log:    a test for parenthesis error msgs

diff --git a/pypy/interpreter/pyparser/test/test_pytokenizer.py 
b/pypy/interpreter/pyparser/test/test_pytokenizer.py
--- a/pypy/interpreter/pyparser/test/test_pytokenizer.py
+++ b/pypy/interpreter/pyparser/test/test_pytokenizer.py
@@ -1,9 +1,16 @@
+import pytest
 from pypy.interpreter.pyparser import pytokenizer
 from pypy.interpreter.pyparser.pygram import tokens
+from pypy.interpreter.pyparser.error import TokenError
 
 def tokenize(s):
     return pytokenizer.generate_tokens(s.splitlines(True) + ["\n"], 0)
 
+def check_token_error(s, msg):
+    error = pytest.raises(TokenError, tokenize, s)
+    assert error.value.msg == msg
+
+
 class TestTokenizer(object):
 
     def test_simple(self):
@@ -17,3 +24,14 @@
             (tokens.NEWLINE, '', 2, 0, '\n'),
             (tokens.ENDMARKER, '', 2, 0, ''),
             ]
+
+    def test_error_parenthesis(self):
+        for paren in "([{":
+            check_token_error(paren + "1 + 2",
+                              "parenthesis is never closed")
+
+        for paren in ")]}":
+            check_token_error("1 + 2" + paren,
+                              "unmatched '%s'" % (paren, ))
+
+
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to