summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2011-10-07 19:14:53 (GMT)
committerBarry Warsaw <barry@python.org>2011-10-07 19:14:53 (GMT)
commitcb9c5ba73673be215e10368d160c173788d58e15 (patch)
tree4bf7fbec3477de21b0b196c6b7af589b76d26142 /Lib
parentdd07732af5793d7cd6fcd59c470f519709ff3eec (diff)
downloadcpython-cb9c5ba73673be215e10368d160c173788d58e15.zip
cpython-cb9c5ba73673be215e10368d160c173788d58e15.tar.gz
cpython-cb9c5ba73673be215e10368d160c173788d58e15.tar.bz2
- Re-enable lib2to3's test_parser.py tests, though with an expected failure
(see issue 13125).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/lib2to3/tests/test_parser.py24
-rw-r--r--Lib/test/test_lib2to3.py3
2 files changed, 17 insertions, 10 deletions
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py
index f389795..60e5d63 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -14,6 +14,7 @@ from .support import driver, test_dir
# Python imports
import os
+import unittest
# Local imports
from lib2to3.pgen2 import tokenize
@@ -157,6 +158,8 @@ class TestParserIdempotency(support.TestCase):
"""A cut-down version of pytree_idempotency.py."""
+ # Issue 13125
+ @unittest.expectedFailure
def test_all_project_files(self):
for filepath in support.all_project_files():
with open(filepath, "rb") as fp:
@@ -165,8 +168,11 @@ class TestParserIdempotency(support.TestCase):
"can't detect encoding for %s" % filepath)
with open(filepath, "r") as fp:
source = fp.read()
- source = source.decode(encoding)
- tree = driver.parse_string(source)
+ try:
+ tree = driver.parse_string(source)
+ except ParseError as err:
+ print('ParseError on file', filepath, err)
+ continue
new = str(tree)
if encoding:
new = new.encode(encoding)
@@ -212,14 +218,14 @@ class TestLiterals(GrammarTest):
self.validate(s)
-def diff(fn, result, encoding):
- f = open("@", "w")
- try:
- f.write(result.encode(encoding))
- finally:
- f.close()
+def diff(fn, result):
try:
+ with open('@', 'w') as f:
+ f.write(str(result))
fn = fn.replace('"', '\\"')
return os.system('diff -u "%s" @' % fn)
finally:
- os.remove("@")
+ try:
+ os.remove("@")
+ except OSError:
+ pass
diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py
index 0d6f9a3..24b2da6 100644
--- a/Lib/test/test_lib2to3.py
+++ b/Lib/test/test_lib2to3.py
@@ -1,6 +1,7 @@
# Skipping test_parser and test_all_fixers
# because of running
from lib2to3.tests import (test_fixers, test_pytree, test_util, test_refactor,
+ test_parser,
test_main as test_main_)
import unittest
from test.support import run_unittest
@@ -8,7 +9,7 @@ from test.support import run_unittest
def suite():
tests = unittest.TestSuite()
loader = unittest.TestLoader()
- for m in (test_fixers, test_pytree,test_util, test_refactor,
+ for m in (test_fixers, test_pytree,test_util, test_refactor, test_parser,
test_main_):
tests.addTests(loader.loadTestsFromModule(m))
return tests