"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Cheetah/Tests/ImportHooks.py" between
cheetah3-3.2.2.tar.gz and cheetah3-3.2.3.tar.gz

About: Cheetah3 is a template engine and code generation tool for e.g. for Web development or Java, SQL, LaTeX, form email ... (written in Python).

ImportHooks.py  (cheetah3-3.2.2):ImportHooks.py  (cheetah3-3.2.3)
#!/usr/bin/env python
from glob import glob from glob import glob
import os import os
import shutil import shutil
import sys import sys
import unittest import unittest
import Cheetah.ImportHooks import Cheetah.ImportHooks
ImportHooksTemplatesDir = os.path.join( ImportHooksTemplatesDir = os.path.join(
os.path.dirname(__file__), 'ImportHooksTemplates') os.path.dirname(__file__), 'ImportHooksTemplates')
skipping to change at line 38 skipping to change at line 36
for modname in list(sys.modules.keys()): for modname in list(sys.modules.keys()):
if '.ImportHooksTemplates.' in modname \ if '.ImportHooksTemplates.' in modname \
or modname.endswith('.ImportHooksTemplates'): or modname.endswith('.ImportHooksTemplates'):
del sys.modules[modname] del sys.modules[modname]
for modname in 'index', 'layout': for modname in 'index', 'layout':
if modname in sys.modules: if modname in sys.modules:
del sys.modules[modname] del sys.modules[modname]
Cheetah.ImportHooks.uninstall()
def _exec(code, _dict): def _exec(code, _dict):
exec(code, _dict) exec(code, _dict)
class ImportHooksTest(unittest.TestCase): class ImportHooksTest(unittest.TestCase):
def setUp(self): def setUp(self):
_cleanup() _cleanup()
def tearDown(self):
_cleanup()
def test_CheetahDirOwner(self): def test_CheetahDirOwner(self):
templates = list(sorted(os.listdir(ImportHooksTemplatesDir))) templates = list(sorted(os.listdir(ImportHooksTemplatesDir)))
self.assertListEqual(templates, ['index.tmpl', 'layout.tmpl']) self.assertListEqual(templates, ['index.tmpl', 'layout.tmpl'])
cdo = Cheetah.ImportHooks.CheetahDirOwner(ImportHooksTemplatesDir) cdo = Cheetah.ImportHooks.CheetahDirOwner(ImportHooksTemplatesDir)
index_mod = cdo.getmod('index') index_mod = cdo.getmod('index')
templates = os.listdir(ImportHooksTemplatesDir) templates = os.listdir(ImportHooksTemplatesDir)
self.assertIn('index.py', templates) self.assertIn('index.py', templates)
self.assertNotIn('layout.py', templates) self.assertNotIn('layout.py', templates)
skipping to change at line 71 skipping to change at line 74
def test_ImportHooks(self): def test_ImportHooks(self):
templates = os.listdir(ImportHooksTemplatesDir) templates = os.listdir(ImportHooksTemplatesDir)
self.assertNotIn('index.py', templates) self.assertNotIn('index.py', templates)
self.assertNotIn('layout.py', templates) self.assertNotIn('layout.py', templates)
Cheetah.ImportHooks.install() Cheetah.ImportHooks.install()
from index import index # noqa from index import index # noqa
templates = os.listdir(ImportHooksTemplatesDir) templates = os.listdir(ImportHooksTemplatesDir)
self.assertIn('index.py', templates) self.assertIn('index.py', templates)
self.assertIn('layout.py', templates) self.assertIn('layout.py', templates)
Cheetah.ImportHooks.uninstall()
if __name__ == '__main__': def test_import_builtin(self):
unittest.main() Cheetah.ImportHooks.install()
for nm in sys.builtin_module_names:
if nm not in sys.modules:
__import__(nm)
return
raise self.fail("All builtin modules are imported")
 End of changes. 5 change blocks. 
3 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)