Permalink
Browse files

Fix test failure on webob.static on Pypy

  • Loading branch information...
1 parent b282e82 commit 7491657ad3f6a70c2e27a049e5826ffdbd0cce76 @multani multani committed Apr 12, 2012
Showing with 7 additions and 9 deletions.
  1. +4 −8 tests/test_static.py
  2. +3 −1 webob/static.py
View
@@ -79,16 +79,12 @@ def open_oserror(*args, **kwargs):
raise OSError()
app = static.FileApp(self.tempfile)
- old_open = __builtins__['open']
- try:
- __builtins__['open'] = open_ioerror
- self.assertEqual(403, get_response(app).status_int)
+ app._open = open_ioerror
+ self.assertEqual(403, get_response(app).status_int)
- __builtins__['open'] = open_oserror
- self.assertEqual(403, get_response(app).status_int)
- finally:
- __builtins__['open'] = old_open
+ app._open = open_oserror
+ self.assertEqual(403, get_response(app).status_int)
class TestFileIter(unittest.TestCase):
View
@@ -27,6 +27,8 @@ def __init__(self, filename, **kw):
kw.setdefault('content_encoding', content_encoding)
kw.setdefault('accept_ranges', 'bytes')
self.kw = kw
+ # Used for testing purpose
+ self._open = open
@wsgify
def __call__(self, req):
@@ -40,7 +42,7 @@ def __call__(self, req):
return exc.HTTPNotFound(comment=msg)
try:
- file = open(self.filename, 'rb')
+ file = self._open(self.filename, 'rb')
except (IOError, OSError) as e:
msg = "You are not permitted to view this file (%s)" % e
return exc.HTTPForbidden(msg)

0 comments on commit 7491657

Please sign in to comment.