summaryrefslogtreecommitdiff
path: root/cheetah/Tests
diff options
context:
space:
mode:
authorR. Tyler Ballance <tyler@monkeypox.org>2009-11-16 20:58:13 -0800
committerR. Tyler Ballance <tyler@monkeypox.org>2009-11-16 21:10:04 -0800
commit7c8e1d15feebb97d27d651c539bea9becdbfc15c (patch)
treeec3dc2de79650238cb203c1a42db709ecf4a1a7e /cheetah/Tests
parente43765a679b84c52df875e9629d303e304af50a1 (diff)
downloadpython-cheetah-7c8e1d15feebb97d27d651c539bea9becdbfc15c.tar.gz
Introduce the DirectiveAnalyzer for processing templates for directive usage
Hoping to form this into a fully-fledged reporting tool so I can gauge usage of directives to start cutting some out.
Diffstat (limited to 'cheetah/Tests')
-rw-r--r--cheetah/Tests/Analyzer.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/cheetah/Tests/Analyzer.py b/cheetah/Tests/Analyzer.py
new file mode 100644
index 0000000..59f6c1c
--- /dev/null
+++ b/cheetah/Tests/Analyzer.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import unittest
+
+from Cheetah import DirectiveAnalyzer
+
+
+class AnalyzerTests(unittest.TestCase):
+ def test_set(self):
+ template = '''
+ #set $foo = "bar"
+ Hello ${foo}!
+ '''
+ calls = DirectiveAnalyzer.analyze(template)
+ self.assertEquals(1, calls.get('set'))
+
+ def test_compilersettings(self):
+ template = '''
+#compiler-settings
+useNameMapper = False
+#end compiler-settings
+ '''
+ calls = DirectiveAnalyzer.analyze(template)
+ self.assertEquals(1, calls.get('compiler-settings'))
+
+
+if __name__ == '__main__':
+ unittest.main()
+