summaryrefslogtreecommitdiff
path: root/test/testyacc.py
diff options
context:
space:
mode:
authorDavid Beazley <dave@dabeaz.com>2011-02-17 21:28:50 -0600
committerDavid Beazley <dave@dabeaz.com>2011-02-17 21:28:50 -0600
commit1e114fed2ecf8c8b603c194a7ce07232eccad2e6 (patch)
tree5f48c7b55fd27b48c0471ca3034f06dfd7322a84 /test/testyacc.py
parent124f030bb2de1e56fb4f09774ea862ac5a572ec4 (diff)
downloadply-1e114fed2ecf8c8b603c194a7ce07232eccad2e6.tar.gz
Fixed for Python 3.2
Diffstat (limited to 'test/testyacc.py')
-rw-r--r--test/testyacc.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/testyacc.py b/test/testyacc.py
index cc53b6d..2b06b44 100644
--- a/test/testyacc.py
+++ b/test/testyacc.py
@@ -8,11 +8,32 @@ except ImportError:
import sys
import os
+import warnings
sys.path.insert(0,"..")
sys.tracebacklimit = 0
import ply.yacc
+import imp
+
+def make_pymodule_path(filename):
+ path = os.path.dirname(filename)
+ file = os.path.basename(filename)
+ mod, ext = os.path.splitext(file)
+
+ if sys.hexversion >= 0x3020000:
+ modname = mod+"."+imp.get_tag()+ext
+ fullpath = os.path.join(path,'__pycache__',modname)
+ else:
+ fullpath = filename
+ return fullpath
+
+def pymodule_out_exists(filename):
+ return os.path.exists(make_pymodule_path(filename))
+
+def pymodule_out_remove(filename):
+ os.remove(make_pymodule_path(filename))
+
def check_expected(result,expected):
resultlines = []
@@ -43,10 +64,13 @@ class YaccErrorWarningTests(unittest.TestCase):
sys.stdout = StringIO.StringIO()
try:
os.remove("parsetab.py")
- os.remove("parsetab.pyc")
+ pymodule_out_remove("parsetab.pyc")
except OSError:
pass
+ if sys.hexversion >= 0x3020000:
+ warnings.filterwarnings('ignore',category=ResourceWarning)
+
def tearDown(self):
sys.stderr = sys.__stderr__
sys.stdout = sys.__stdout__
@@ -297,7 +321,6 @@ class YaccErrorWarningTests(unittest.TestCase):
def test_yacc_uprec(self):
self.assertRaises(ply.yacc.YaccError,run_import,"yacc_uprec")
result = sys.stderr.getvalue()
- print repr(result)
self.assert_(check_expected(result,
"yacc_uprec.py:37: Nothing known about the precedence of 'UMINUS'\n"
))