[pypy-svn] r49157 - pypy/dist/pypy/interpreter/pyparser/test

pedronis at codespeak.net pedronis at codespeak.net
Mon Nov 26 09:33:48 CET 2007


Author: pedronis
Date: Mon Nov 26 09:33:47 2007
New Revision: 49157

Modified:
   pypy/dist/pypy/interpreter/pyparser/test/test_pytokenizer.py
Log:
one more test we ended up writing around here when resuing some of this code



Modified: pypy/dist/pypy/interpreter/pyparser/test/test_pytokenizer.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/test/test_pytokenizer.py	(original)
+++ pypy/dist/pypy/interpreter/pyparser/test/test_pytokenizer.py	Mon Nov 26 09:33:47 2007
@@ -1,7 +1,7 @@
 from pypy.interpreter.pyparser.pythonlexer import Source, TokenError, \
      match_encoding_declaration
 from pypy.interpreter.pyparser.grammar import Token, GrammarElement
-from pypy.interpreter.pyparser.pythonparse import make_pyparser
+from pypy.interpreter.pyparser.pythonparse import make_pyparser, _check_for_encoding
 
 P = make_pyparser('2.4')
 
@@ -108,3 +108,17 @@
     for comment, encoding in checks:
         res = match_encoding_declaration(comment)
         assert res == encoding, "Failed on (%s), %s != %s" % (comment, res, encoding)
+
+
+def test_check_for_enconding():
+    
+    res = _check_for_encoding("# foo")
+    assert res is None
+    res = _check_for_encoding("# -*- coding: ascii -*-  ")
+    assert res == "ascii"    
+    res = _check_for_encoding("# -*- coding: iso-8859-15 -*-  ")
+    assert res == "iso-8859-15"
+    res = _check_for_encoding("\n   # -*- coding: iso-8859-15 -*-  \n")
+    assert res == "iso-8859-15"
+    res = _check_for_encoding("\n\n   # -*- coding: iso-8859-15 -*-  \n")
+    assert res is None   



More information about the Pypy-commit mailing list