summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beazley <dave@dabeaz.com>2015-04-25 19:34:28 -0500
committerDavid Beazley <dave@dabeaz.com>2015-04-25 19:34:28 -0500
commited2f634bf9ae7d75da716d18d6994dc1952fdfd0 (patch)
treed7b4b69428f6caacbb77220366603cc9f2e8ec3a
parent9bb220d50391eda55bc45c29f16cd69859bc95a8 (diff)
downloadply-ed2f634bf9ae7d75da716d18d6994dc1952fdfd0.tar.gz
Fixed permissions test
-rw-r--r--test/pkg_test4/__init__.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/pkg_test4/__init__.py b/test/pkg_test4/__init__.py
index 0e19558..ba9ddac 100644
--- a/test/pkg_test4/__init__.py
+++ b/test/pkg_test4/__init__.py
@@ -1,9 +1,25 @@
# Tests proper handling of lextab and parsetab files in package structures
+# Check of warning messages when files aren't writable
# Here for testing purposes
import sys
if '..' not in sys.path:
sys.path.insert(0, '..')
-from .parsing.calcparse import parser
+import ply.lex
+import ply.yacc
+
+def patched_open(filename, mode):
+ if 'w' in mode:
+ raise IOError("Permission denied %r" % filename)
+ return open(filename, mode)
+
+ply.lex.open = patched_open
+ply.yacc.open = patched_open
+try:
+ from .parsing.calcparse import parser
+finally:
+ del ply.lex.open
+ del ply.yacc.open
+