diff options
-rwxr-xr-x | bottle.py | 2 | ||||
-rw-r--r-- | test/test_importhook.py | 9 |
2 files changed, 9 insertions, 2 deletions
@@ -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() |