2 new revisions:

Revision: 55c93d009768
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 09:18:55 2011
Log:      testoutput: cleanup imports
http://code.google.com/p/robotframework/source/detail?r=55c93d009768

Revision: 0194590eef33
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 09:19:23 2011
Log:      moved templating module to utils
http://code.google.com/p/robotframework/source/detail?r=0194590eef33

==============================================================================
Revision: 55c93d009768
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 09:18:55 2011
Log:      testoutput: cleanup imports
http://code.google.com/p/robotframework/source/detail?r=55c93d009768

Modified:
 /src/robot/serializing/testoutput.py

=======================================
--- /src/robot/serializing/testoutput.py        Wed Jun 15 09:04:54 2011
+++ /src/robot/serializing/testoutput.py        Wed Jun 15 09:18:55 2011
@@ -18,10 +18,8 @@

 from robot import utils
 from robot.common import Statistics
-from robot.output import LOGGER, process_outputs, process_output
-from robot.version import get_full_version
-
-from templating import Namespace, Template
+from robot.output import LOGGER, process_outputs
+
 from outputserializers import OutputSerializer
 from xunitserializers import XUnitSerializer
 from robot.serializing.serialize_log import serialize_log, serialize_report

==============================================================================
Revision: 0194590eef33
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 09:19:23 2011
Log:      moved templating module to utils
http://code.google.com/p/robotframework/source/detail?r=0194590eef33

Added:
 /src/robot/utils/templating.py
 /utest/utils/test_templating.py
Deleted:
 /src/robot/serializing/templating.py
 /utest/serializing/test_templating.py
Modified:
 /src/robot/serializing/__init__.py
 /tools/libdoc/libdoc.py

=======================================
--- /dev/null
+++ /src/robot/utils/templating.py      Wed Jun 15 09:19:23 2011
@@ -0,0 +1,201 @@
+#  Copyright 2008-2011 Nokia Siemens Networks Oyj
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+
+import os.path
+
+from robot.variables import Variables
+from robot.errors import DataError, FrameworkError
+from robot import utils
+
+
+PRE = '<!-- '
+POST = ' -->'
+
+
+class Namespace(Variables):
+
+    def __init__(self, **kwargs):
+        Variables.__init__(self, ['$'])
+        for key, value in kwargs.items():
+            self['${%s}' % key] = value
+
+
+class Template:
+
+    def __init__(self, path=None, template=None, functions=None):
+        if path is None and template is None:
+ raise FrameworkError("Either 'path' or 'template' must be given")
+        if template is None:
+            tfile = open(path)
+            template = tfile.read()
+            tfile.close()
+            self.parent_dir = os.path.dirname(utils.abspath(path))
+        else:
+            self.parent_dir = None
+        self._template = template
+        self._functions = functions or utils.NormalizedDict()
+        # True means handlers for more than single line
+        self._handlers = { 'INCLUDE': (self._handle_include, False),
+                           'IMPORT': (self._handle_import, False),
+                           'CALL': (self._handle_call, False),
+                           'IF': (self._handle_if, True),
+                           'FOR': (self._handle_for, True),
+                           'FUNCTION': (self._handle_function, True) }
+
+    def generate(self, namespace, output=None):
+        self._namespace = namespace
+        return self._process(self._template, output)
+
+    def _process(self, template, output=None):
+        result = Result(output)
+        lines = template.splitlines()
+        while lines:
+            line = lines.pop(0)
+            try:
+                result.add(self._process_line(line.strip(), lines))
+            except ValueError:
+                result.add(self._handle_variables(line))
+        return result.get_result()
+
+    def _process_line(self, line, lines):
+        if not line.startswith(PRE) and line.endswith(POST):
+            raise ValueError
+        name, expression = line[len(PRE):-len(POST)].split(' ', 1)
+        try:
+            handler, multiline = self._handlers[name]
+        except KeyError:
+            raise ValueError
+        if multiline:
+            block_lines = self._get_multi_line_block(name, lines)
+            return handler(expression, block_lines)
+        return handler(expression)
+
+    def _get_multi_line_block(self, name, lines):
+        """Returns string containing lines before END matching given name.
+
+        Removes the returned lines from given 'lines'.
+        """
+        block_lines = []
+        endline = '%sEND %s%s' % (PRE, name, POST)
+        while True:
+            try:
+                line = lines.pop(0)
+            except IndexError:
+                raise DataError('Invalid template: No END for %s' % name)
+            if line.strip() == endline:
+                break
+            block_lines.append(line)
+        return block_lines
+
+    def _handle_variables(self, template):
+        return self._namespace.replace_string(template)
+
+    def _handle_include(self, path):
+        included_file = open(self._get_full_path(path))
+        include = included_file.read()
+        included_file.close()
+        return self._handle_variables(include)
+
+    def _handle_import(self, path):
+        imported_file = open(self._get_full_path(path))
+        self._process(imported_file.read())
+        imported_file.close()
+        return None
+
+    def _handle_for(self, expression, block_lines):
+        block = '\n'.join(block_lines)
+        result = []
+        var_name, _, value_list = expression.split(' ', 2)
+        namespace = self._namespace.copy()
+        for value in namespace.replace_scalar(value_list):
+            namespace[var_name] = value
+            temp = Template(template=block, functions=self._functions)
+            ret = temp.generate(namespace)
+            if ret:
+                result.append(ret)
+        if not result:
+            return None
+        return '\n'.join(result)
+
+    def _handle_if(self, expression, block_lines):
+        expression = self._handle_variables(expression)
+        if_block, else_block = self._get_if_and_else_blocks(block_lines)
+        result = eval(expression) and if_block or else_block
+        if not result:
+            return None
+        return self._process('\n'.join(result))
+
+    def _get_if_and_else_blocks(self, block_lines):
+        else_line = PRE + 'ELSE' + POST
+        if_block = []
+        else_block = []
+        block = if_block
+        for line in block_lines:
+            if line.strip() == else_line:
+                block = else_block
+            else:
+                block.append(line)
+        return if_block, else_block
+
+    def _handle_call(self, expression):
+        func_tokens = expression.split()
+        name = func_tokens[0]
+        args = func_tokens[1:]
+        namespace = self._namespace.copy()
+        try:
+            func_args, func_body = self._functions[name]
+        except KeyError:
+            raise DataError("Non-existing function '%s', available: %s"
+                            % (name, self._functions.keys()))
+        for key, value in zip(func_args, args):
+            namespace[key] = namespace.replace_string(value)
+        temp = Template(template=func_body, functions=self._functions)
+        return temp.generate(namespace)
+
+    def _handle_function(self, signature, block_lines):
+        signature_tokens = signature.split()
+        name = signature_tokens[0]
+        args = signature_tokens[1:]
+        self._functions[name] = (args, '\n'.join(block_lines))
+
+    def _get_full_path(self, path):
+        if self.parent_dir is None:
+ raise FrameworkError('Parent directory is None. Probably template ' + 'was string and other files was referred. '
+                                 'That is not supported.')
+        abs_path = os.path.join(self.parent_dir, path)
+        if os.path.exists(abs_path):
+            return abs_path
+        else:
+            raise DataError("File '%s' does not exist." % abs_path)
+
+
+class Result:
+
+    def __init__(self, output=None):
+        self._output = output
+        self._result = []
+
+    def add(self, text):
+        if text is not None:
+            if self._output is None:
+                self._result.append(text)
+            else:
+                self._output.write(text.encode('UTF-8') + '\n')
+
+    def get_result(self):
+        if not self._result:
+            return None
+        return '\n'.join(self._result)
=======================================
--- /dev/null
+++ /utest/utils/test_templating.py     Wed Jun 15 09:19:23 2011
@@ -0,0 +1,157 @@
+import unittest
+import StringIO
+
+from robot.utils.asserts import *
+from robot.utils.templating import Template, Namespace
+
+
+class TemplateWithOverridenInit(Template):
+    def __init__(self):
+        pass
+
+T = TemplateWithOverridenInit
+N = Namespace
+
+
+class TestTemplate(unittest.TestCase):
+
+
+    def test_replace_nothing(self):
+        t = T()
+        t._namespace = N()
+        assert_equals(t._handle_variables('hi world') , 'hi world')
+
+    def test_replace_string(self):
+        t = T()
+        handler = t._handle_variables
+        t._namespace = N(name='world')
+        assert_equals(handler('hi ${name}'), 'hi world')
+        t._namespace = N(name='moon')
+        assert_equals(handler('hi ${name}'), 'hi moon')
+        t._namespace = N(f='h',o='a')
+        assert_equals(handler('${f}${o}${o}'), 'haa')
+
+    def test_if(self):
+        template = '1\n<!-- IF ${x} == 0 -->\n${num}\n<!-- END IF -->\n3\n'
+        temp = Template(template=template)
+        assert_equals(temp.generate(N(num='2',x=0)), '1\n2\n3')
+        assert_equals(temp.generate(N(num='2',x=1)), '1\n3')
+
+    def test_if_else(self):
+        template = '1\n<!-- IF ${x} == 0 -->\na = ${a}\n<!-- ELSE -->\n'
+        template += 'b = ${b}\n<!-- END IF -->\n3'
+        temp = Template(template=template)
+        assert_equals(temp.generate(N(a='a',b='b',x=0)), '1\na = a\n3')
+        assert_equals(temp.generate(N(a='a',b='b',x=1)), '1\nb = b\n3')
+
+    def test_very_long_if_else(self):
+        at = 25000
+        bt = 10000
+        template = '1\n<!-- IF ${x} == 0 -->\n'
+        template += 'a'*at
+        template += '\n<!-- ELSE -->\n'
+        template += 'b'*bt
+        template += '\n<!-- END IF -->\n3'
+        temp = Template(template=template)
+        assert_equals(temp.generate(N(x=0)), '1\n%s\n3' % ('a'*at))
+        assert_equals(temp.generate(N(x=1)), '1\n%s\n3' % ('b'*bt))
+
+    def test_two_ifs(self):
+ template = '1\n<!-- IF ${x} == 0 -->\nx=0\n<!-- ELSE -->\nx=1\n<!-- END IF -->\n2\n' + template += '3\n<!-- IF ${y} == 0 -->\ny=0\n<!-- ELSE -->\ny=1\n<!-- END IF -->\n4\n'
+        temp = Template(template=template)
+        assert_equals(temp.generate(N(x=0, y=0)), '1\nx=0\n2\n3\ny=0\n4')
+
+    def test_for(self):
+        template = '0\n<!-- FOR ${num} in ${numbers} -->\n'
+        template += '${num}\n'
+        template += '<!-- END FOR -->\n10\n'
+        temp = Template(template=template)
+        assert_equals(temp.generate(N(x=0, numbers=[])), '0\n10')
+ assert_equals(temp.generate(N(x=0, numbers='1 2 3 4 5 6 7 8 9'.split())),
+                      '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10')
+
+    def test_for_with_if_inside(self):
+        template = '1\n<!-- FOR ${test} in ${tests} -->\n'
+        template += '<!-- IF ${x} == 0 -->\n'
+        template += 'name:${test}\n'
+        template += '<!-- END IF -->\n'
+        template += '<!-- END FOR -->\n2\n'
+        temp = Template(template=template)
+        assert_equals(temp.generate(N(x=0, tests=[])), '1\n2')
+        assert_equals(temp.generate(N(x=0, tests=['test1', 'test2'])),
+                      '1\nname:test1\nname:test2\n2')
+
+    def test_functions(self):
+        template = '1\n'
+        template += '<!-- FUNCTION func1 ${arg1} ${arg2} -->\n'
+        template += ' Hello ${arg1}!\nHi ${arg2}\n'
+        template += '<!-- END FUNCTION -->\n'
+        template += '2\n'
+ template += '<!-- FUNCTION func2 -->\nHi you!\n<!-- END FUNCTION -->\n'
+        template += '3\n'
+        temp = Template(template=template)
+        temp.generate(N())
+        for name, args, body in [
+ ( 'func1', ['${arg1}', '${arg2}'], ' Hello ${arg1}!\nHi ${arg2}'),
+            ( 'func2', [], 'Hi you!')
+            ]:
+            assert_true(temp._functions.has_key(name))
+            act_args, act_body = temp._functions[name]
+            assert_equals(act_args, args)
+            assert_equals(act_body, body)
+
+    def test_call(self):
+        temp = Template(template='''
+<!-- FUNCTION func1 ${arg1} ${arg2} -->
+Hello ${arg1}!
+Hi ${arg2}
+<!-- END FUNCTION -->
+
+<!-- FUNCTION func2 -->
+Hi you!
+<!-- END FUNCTION -->
+
+<!-- CALL func1 world me -->
+<!-- CALL func2 -->
+''')
+        assert_equals(temp.generate(N()), '''
+
+
+Hello world!
+Hi me
+Hi you!''')
+
+    def test_output(self):
+        temp = Template(template='''
+<!-- FUNCTION func1 ${arg1} ${arg2} -->
+  Hello ${arg1}!
+  Hi ${arg2}!
+<!-- END FUNCTION -->
+<!-- FUNCTION func2 -->
+Hi you!
+<!-- END FUNCTION -->
+
+<!-- CALL func1 world me -->
+
+<!-- CALL func2 -->
+
+${hello}
+''')
+        output = StringIO.StringIO()
+        ret = temp.generate(N(hello='Hi tellus!'), output)
+        assert_none(ret)
+        output.flush()
+        assert_equals(output.getvalue(), '''
+
+  Hello world!
+  Hi me!
+
+Hi you!
+
+Hi tellus!
+''')
+
+
+if __name__ == '__main__':
+    unittest.main()
=======================================
--- /src/robot/serializing/templating.py        Fri Apr 15 14:27:57 2011
+++ /dev/null
@@ -1,201 +0,0 @@
-#  Copyright 2008-2011 Nokia Siemens Networks Oyj
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-
-
-import os.path
-
-from robot.variables import Variables
-from robot.errors import DataError, FrameworkError
-from robot import utils
-
-
-PRE = '<!-- '
-POST = ' -->'
-
-
-class Namespace(Variables):
-
-    def __init__(self, **kwargs):
-        Variables.__init__(self, ['$'])
-        for key, value in kwargs.items():
-            self['${%s}' % key] = value
-
-
-class Template:
-
-    def __init__(self, path=None, template=None, functions=None):
-        if path is None and template is None:
- raise FrameworkError("Either 'path' or 'template' must be given")
-        if template is None:
-            tfile = open(path)
-            template = tfile.read()
-            tfile.close()
-            self.parent_dir = os.path.dirname(utils.abspath(path))
-        else:
-            self.parent_dir = None
-        self._template = template
-        self._functions = functions or utils.NormalizedDict()
-        # True means handlers for more than single line
-        self._handlers = { 'INCLUDE': (self._handle_include, False),
-                           'IMPORT': (self._handle_import, False),
-                           'CALL': (self._handle_call, False),
-                           'IF': (self._handle_if, True),
-                           'FOR': (self._handle_for, True),
-                           'FUNCTION': (self._handle_function, True) }
-
-    def generate(self, namespace, output=None):
-        self._namespace = namespace
-        return self._process(self._template, output)
-
-    def _process(self, template, output=None):
-        result = Result(output)
-        lines = template.splitlines()
-        while lines:
-            line = lines.pop(0)
-            try:
-                result.add(self._process_line(line.strip(), lines))
-            except ValueError:
-                result.add(self._handle_variables(line))
-        return result.get_result()
-
-    def _process_line(self, line, lines):
-        if not line.startswith(PRE) and line.endswith(POST):
-            raise ValueError
-        name, expression = line[len(PRE):-len(POST)].split(' ', 1)
-        try:
-            handler, multiline = self._handlers[name]
-        except KeyError:
-            raise ValueError
-        if multiline:
-            block_lines = self._get_multi_line_block(name, lines)
-            return handler(expression, block_lines)
-        return handler(expression)
-
-    def _get_multi_line_block(self, name, lines):
-        """Returns string containing lines before END matching given name.
-
-        Removes the returned lines from given 'lines'.
-        """
-        block_lines = []
-        endline = '%sEND %s%s' % (PRE, name, POST)
-        while True:
-            try:
-                line = lines.pop(0)
-            except IndexError:
-                raise DataError('Invalid template: No END for %s' % name)
-            if line.strip() == endline:
-                break
-            block_lines.append(line)
-        return block_lines
-
-    def _handle_variables(self, template):
-        return self._namespace.replace_string(template)
-
-    def _handle_include(self, path):
-        included_file = open(self._get_full_path(path))
-        include = included_file.read()
-        included_file.close()
-        return self._handle_variables(include)
-
-    def _handle_import(self, path):
-        imported_file = open(self._get_full_path(path))
-        self._process(imported_file.read())
-        imported_file.close()
-        return None
-
-    def _handle_for(self, expression, block_lines):
-        block = '\n'.join(block_lines)
-        result = []
-        var_name, _, value_list = expression.split(' ', 2)
-        namespace = self._namespace.copy()
-        for value in namespace.replace_scalar(value_list):
-            namespace[var_name] = value
-            temp = Template(template=block, functions=self._functions)
-            ret = temp.generate(namespace)
-            if ret:
-                result.append(ret)
-        if not result:
-            return None
-        return '\n'.join(result)
-
-    def _handle_if(self, expression, block_lines):
-        expression = self._handle_variables(expression)
-        if_block, else_block = self._get_if_and_else_blocks(block_lines)
-        result = eval(expression) and if_block or else_block
-        if not result:
-            return None
-        return self._process('\n'.join(result))
-
-    def _get_if_and_else_blocks(self, block_lines):
-        else_line = PRE + 'ELSE' + POST
-        if_block = []
-        else_block = []
-        block = if_block
-        for line in block_lines:
-            if line.strip() == else_line:
-                block = else_block
-            else:
-                block.append(line)
-        return if_block, else_block
-
-    def _handle_call(self, expression):
-        func_tokens = expression.split()
-        name = func_tokens[0]
-        args = func_tokens[1:]
-        namespace = self._namespace.copy()
-        try:
-            func_args, func_body = self._functions[name]
-        except KeyError:
-            raise DataError("Non-existing function '%s', available: %s"
-                            % (name, self._functions.keys()))
-        for key, value in zip(func_args, args):
-            namespace[key] = namespace.replace_string(value)
-        temp = Template(template=func_body, functions=self._functions)
-        return temp.generate(namespace)
-
-    def _handle_function(self, signature, block_lines):
-        signature_tokens = signature.split()
-        name = signature_tokens[0]
-        args = signature_tokens[1:]
-        self._functions[name] = (args, '\n'.join(block_lines))
-
-    def _get_full_path(self, path):
-        if self.parent_dir is None:
- raise FrameworkError('Parent directory is None. Probably template ' - 'was string and other files was referred. '
-                                 'That is not supported.')
-        abs_path = os.path.join(self.parent_dir, path)
-        if os.path.exists(abs_path):
-            return abs_path
-        else:
-            raise DataError("File '%s' does not exist." % abs_path)
-
-
-class Result:
-
-    def __init__(self, output=None):
-        self._output = output
-        self._result = []
-
-    def add(self, text):
-        if text is not None:
-            if self._output is None:
-                self._result.append(text)
-            else:
-                self._output.write(text.encode('UTF-8') + '\n')
-
-    def get_result(self):
-        if not self._result:
-            return None
-        return '\n'.join(self._result)
=======================================
--- /utest/serializing/test_templating.py       Sat May 31 07:42:03 2008
+++ /dev/null
@@ -1,156 +0,0 @@
-import unittest, sys, StringIO
-
-from robot.utils.asserts import *
-from robot.serializing.templating import Template, Namespace
-
-
-class TemplateWithOverridenInit(Template):
-    def __init__(self):
-        pass
-
-T = TemplateWithOverridenInit
-N = Namespace
-
-
-class TestTemplate(unittest.TestCase):
-
-
-    def test_replace_nothing(self):
-        t = T()
-        t._namespace = N()
-        assert_equals(t._handle_variables('hi world') , 'hi world')
-
-    def test_replace_string(self):
-        t = T()
-        handler = t._handle_variables
-        t._namespace = N(name='world')
-        assert_equals(handler('hi ${name}'), 'hi world')
-        t._namespace = N(name='moon')
-        assert_equals(handler('hi ${name}'), 'hi moon')
-        t._namespace = N(f='h',o='a')
-        assert_equals(handler('${f}${o}${o}'), 'haa')
-
-    def test_if(self):
-        template = '1\n<!-- IF ${x} == 0 -->\n${num}\n<!-- END IF -->\n3\n'
-        temp = Template(template=template)
-        assert_equals(temp.generate(N(num='2',x=0)), '1\n2\n3')
-        assert_equals(temp.generate(N(num='2',x=1)), '1\n3')
-
-    def test_if_else(self):
-        template = '1\n<!-- IF ${x} == 0 -->\na = ${a}\n<!-- ELSE -->\n'
-        template += 'b = ${b}\n<!-- END IF -->\n3'
-        temp = Template(template=template)
-        assert_equals(temp.generate(N(a='a',b='b',x=0)), '1\na = a\n3')
-        assert_equals(temp.generate(N(a='a',b='b',x=1)), '1\nb = b\n3')
-
-    def test_very_long_if_else(self):
-        at = 25000
-        bt = 10000
-        template = '1\n<!-- IF ${x} == 0 -->\n'
-        template += 'a'*at
-        template += '\n<!-- ELSE -->\n'
-        template += 'b'*bt
-        template += '\n<!-- END IF -->\n3'
-        temp = Template(template=template)
-        assert_equals(temp.generate(N(x=0)), '1\n%s\n3' % ('a'*at))
-        assert_equals(temp.generate(N(x=1)), '1\n%s\n3' % ('b'*bt))
-
-    def test_two_ifs(self):
- template = '1\n<!-- IF ${x} == 0 -->\nx=0\n<!-- ELSE -->\nx=1\n<!-- END IF -->\n2\n' - template += '3\n<!-- IF ${y} == 0 -->\ny=0\n<!-- ELSE -->\ny=1\n<!-- END IF -->\n4\n'
-        temp = Template(template=template)
-        assert_equals(temp.generate(N(x=0, y=0)), '1\nx=0\n2\n3\ny=0\n4')
-
-    def test_for(self):
-        template = '0\n<!-- FOR ${num} in ${numbers} -->\n'
-        template += '${num}\n'
-        template += '<!-- END FOR -->\n10\n'
-        temp = Template(template=template)
-        assert_equals(temp.generate(N(x=0, numbers=[])), '0\n10')
- assert_equals(temp.generate(N(x=0, numbers='1 2 3 4 5 6 7 8 9'.split())),
-                      '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10')
-
-    def test_for_with_if_inside(self):
-        template = '1\n<!-- FOR ${test} in ${tests} -->\n'
-        template += '<!-- IF ${x} == 0 -->\n'
-        template += 'name:${test}\n'
-        template += '<!-- END IF -->\n'
-        template += '<!-- END FOR -->\n2\n'
-        temp = Template(template=template)
-        assert_equals(temp.generate(N(x=0, tests=[])), '1\n2')
-        assert_equals(temp.generate(N(x=0, tests=['test1', 'test2'])),
-                      '1\nname:test1\nname:test2\n2')
-
-    def test_functions(self):
-        template = '1\n'
-        template += '<!-- FUNCTION func1 ${arg1} ${arg2} -->\n'
-        template += ' Hello ${arg1}!\nHi ${arg2}\n'
-        template += '<!-- END FUNCTION -->\n'
-        template += '2\n'
- template += '<!-- FUNCTION func2 -->\nHi you!\n<!-- END FUNCTION -->\n'
-        template += '3\n'
-        temp = Template(template=template)
-        temp.generate(N())
-        for name, args, body in [
- ( 'func1', ['${arg1}', '${arg2}'], ' Hello ${arg1}!\nHi ${arg2}'),
-            ( 'func2', [], 'Hi you!')
-            ]:
-            assert_true(temp._functions.has_key(name))
-            act_args, act_body = temp._functions[name]
-            assert_equals(act_args, args)
-            assert_equals(act_body, body)
-
-    def test_call(self):
-        temp = Template(template='''
-<!-- FUNCTION func1 ${arg1} ${arg2} -->
-Hello ${arg1}!
-Hi ${arg2}
-<!-- END FUNCTION -->
-
-<!-- FUNCTION func2 -->
-Hi you!
-<!-- END FUNCTION -->
-
-<!-- CALL func1 world me -->
-<!-- CALL func2 -->
-''')
-        assert_equals(temp.generate(N()), '''
-
-
-Hello world!
-Hi me
-Hi you!''')
-
-    def test_output(self):
-        temp = Template(template='''
-<!-- FUNCTION func1 ${arg1} ${arg2} -->
-  Hello ${arg1}!
-  Hi ${arg2}!
-<!-- END FUNCTION -->
-<!-- FUNCTION func2 -->
-Hi you!
-<!-- END FUNCTION -->
-
-<!-- CALL func1 world me -->
-
-<!-- CALL func2 -->
-
-${hello}
-''')
-        output = StringIO.StringIO()
-        ret = temp.generate(N(hello='Hi tellus!'), output)
-        assert_none(ret)
-        output.flush()
-        assert_equals(output.getvalue(), '''
-
-  Hello world!
-  Hi me!
-
-Hi you!
-
-Hi tellus!
-''')
-
-
-if __name__ == '__main__':
-    unittest.main()
=======================================
--- /src/robot/serializing/__init__.py  Wed Jun 15 04:56:54 2011
+++ /src/robot/serializing/__init__.py  Wed Jun 15 09:19:23 2011
@@ -14,4 +14,3 @@


 from testoutput import RobotTestOutput
-from templating import Template, Namespace
=======================================
--- /tools/libdoc/libdoc.py     Sun Feb  6 01:24:10 2011
+++ /tools/libdoc/libdoc.py     Wed Jun 15 09:19:23 2011
@@ -67,7 +67,7 @@
 from HTMLParser import HTMLParser

 from robot.running import TestLibrary, UserLibrary
-from robot.serializing import Template, Namespace
+from robot.utils.templating import Template, Namespace
 from robot.errors import DataError, Information
 from robot.parsing import populators
 from robot import utils

Reply via email to