summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2011-07-19 21:22:35 +0200
committerMarcel Hellkamp <marc@gsites.de>2011-07-19 21:31:45 +0200
commitd832e7d8da59d46702a4be42597f6cfa152c36ce (patch)
tree6f134a7c1f4def0c24430c73ea5a438cfa69047c
parent0fc3cea31b3d03c12a19895797feb700e05e3423 (diff)
downloadbottle-d832e7d8da59d46702a4be42597f6cfa152c36ce.tar.gz
fix: GAE dev server crash on windows. (fix #183)
Thanks apexi200sx and Marcos Neves
-rwxr-xr-xbottle.py2
-rw-r--r--test/test_importhook.py9
2 files changed, 9 insertions, 2 deletions
diff --git a/bottle.py b/bottle.py
index fb0a5f9..fbfe019 100755
--- a/bottle.py
+++ b/bottle.py
@@ -1245,7 +1245,7 @@ class _ImportRedirect(object):
self.name = name
self.impmask = impmask
self.module = sys.modules.setdefault(name, imp.new_module(name))
- self.module.__dict__.update({'__file__': '<virtual>', '__path__': [],
+ self.module.__dict__.update({'__file__': __file__, '__path__': [],
'__all__': [], '__loader__': self})
sys.meta_path.append(self)
diff --git a/test/test_importhook.py b/test/test_importhook.py
index 827307e..bbb3866 100644
--- a/test/test_importhook.py
+++ b/test/test_importhook.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import unittest
-import sys
+import sys, os
import imp
class TestImportHooks(unittest.TestCase):
@@ -33,5 +33,12 @@ class TestImportHooks(unittest.TestCase):
import bottle.ext.doesnotexist
self.assertRaises(ImportError, test)
+ def test_ext_isfile(self):
+ ''' The virtual module needs a valid __file__ attribute.
+ If not, the Google app engine development server crashes on windows.
+ '''
+ from bottle import ext
+ self.assertTrue(os.path.isfile(ext.__file__))
+
if __name__ == '__main__': #pragma: no cover
unittest.main()