"Fossies" - the Fresh Open Source Software Archive

Member "cheetah3-3.2.6.post2/Cheetah/Tests/LoadTemplate.py" (20 Apr 2021, 1769 Bytes) of package /linux/www/cheetah3-3.2.6.post2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "LoadTemplate.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3-3.2.2_vs_3-3.2.3.

    1 import os
    2 import unittest
    3 import Cheetah.ImportHooks
    4 from Cheetah.LoadTemplate import loadTemplateClass
    5 from Cheetah.Tests.ImportHooks import ImportHooksTemplatesDir, _cleanup
    6 from Cheetah.Tests.ImportHooks import setUpModule, tearDownModule  # noqa
    7 
    8 
    9 class LoadTemplateTest(unittest.TestCase):
   10     def setUp(self):
   11         _cleanup()
   12 
   13     def tearDown(self):
   14         _cleanup()
   15 
   16     def test_loadTemplate(self):
   17         templates = os.listdir(ImportHooksTemplatesDir)
   18         self.assertNotIn('index.py', templates)
   19         self.assertNotIn('layout.py', templates)
   20 
   21         self.assertRaises(ImportError, loadTemplateClass,
   22                           os.path.join(ImportHooksTemplatesDir, 'index.tmpl'))
   23 
   24         templates = os.listdir(ImportHooksTemplatesDir)
   25         self.assertIn('index.py', templates)
   26         self.assertNotIn('layout.py', templates)
   27 
   28         loadTemplateClass(
   29             os.path.join(ImportHooksTemplatesDir, 'layout.tmpl'))
   30 
   31         templates = os.listdir(ImportHooksTemplatesDir)
   32         self.assertIn('index.py', templates)
   33         self.assertIn('layout.py', templates)
   34 
   35         loadTemplateClass(
   36             os.path.join(ImportHooksTemplatesDir, 'index.tmpl'))
   37 
   38         self.assertRaises(ImportError, loadTemplateClass, 'doesnotexist')
   39 
   40     def test_ImportHooks(self):
   41         templates = os.listdir(ImportHooksTemplatesDir)
   42         self.assertNotIn('index.py', templates)
   43         self.assertNotIn('layout.py', templates)
   44 
   45         Cheetah.ImportHooks.install()
   46         loadTemplateClass(
   47             os.path.join(ImportHooksTemplatesDir, 'index.tmpl'))
   48         templates = os.listdir(ImportHooksTemplatesDir)
   49         self.assertIn('index.py', templates)
   50         self.assertIn('layout.py', templates)
   51         Cheetah.ImportHooks.uninstall()