5 new revisions:
Revision: 3ede2930dc80
Author: Pekka Klärck
Date: Wed Dec 14 00:37:51 2011
Log: RebotXMLWriter -> OutputWriter
http://code.google.com/p/robotframework/source/detail?r=3ede2930dc80
Revision: 6860dc3a145a
Author: Pekka Klärck
Date: Wed Dec 14 01:39:40 2011
Log: Fixed XmlWriter tests on Jython < 2.5.2 on Windows.
http://code.google.com/p/robotframework/source/detail?r=6860dc3a145a
Revision: 77c31508bea6
Author: Pekka Klärck
Date: Wed Dec 14 01:41:20 2011
Log: Small XmlWriter enhancements
http://code.google.com/p/robotframework/source/detail?r=77c31508bea6
Revision: 6f27c4dcf507
Author: Pekka Klärck
Date: Wed Dec 14 01:46:23 2011
Log: OutputWriter: Better external API. Internal cleanup still needed
and a...
http://code.google.com/p/robotframework/source/detail?r=6f27c4dcf507
Revision: e2a28b513882
Author: Pekka Klärck
Date: Wed Dec 14 01:46:30 2011
Log: Automated merge with https://robotframework.googlecode.com/hg/
http://code.google.com/p/robotframework/source/detail?r=e2a28b513882
==============================================================================
Revision: 3ede2930dc80
Author: Pekka Klärck
Date: Wed Dec 14 00:37:51 2011
Log: RebotXMLWriter -> OutputWriter
http://code.google.com/p/robotframework/source/detail?r=3ede2930dc80
Added:
/src/robot/result/outputwriter.py
Deleted:
/src/robot/result/serializer.py
Modified:
/src/robot/reporting/builders.py
/src/robot/reporting/resultwriter.py
/utest/result/test_resultserializer.py
=======================================
--- /dev/null
+++ /src/robot/result/outputwriter.py Wed Dec 14 00:37:51 2011
@@ -0,0 +1,49 @@
+# 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.
+
+from robot.output.xmllogger import XmlLogger
+from robot.result.visitor import ResultVisitor
+
+
+class OutputWriter(XmlLogger, ResultVisitor):
+
+ def __init__(self, output):
+ XmlLogger.__init__(self, output, generator='Rebot')
+
+ def start_message(self, msg):
+ self._write_message(msg)
+
+ def close(self):
+ self._writer.end('robot')
+ self._writer.close()
+
+ def start_errors(self, errors):
+ XmlLogger.start_errors(self)
+
+ def end_errors(self, errors):
+ XmlLogger.end_errors(self)
+
+ def end_result(self, result):
+ self.close()
+
+ start_total_statistics = XmlLogger.start_total_stats
+ start_tag_statistics = XmlLogger.start_tag_stats
+ start_suite_statistics = XmlLogger.start_suite_stats
+ end_total_statistics = XmlLogger.end_total_stats
+ end_tag_statistics = XmlLogger.end_tag_stats
+ end_suite_statistics = XmlLogger.end_suite_stats
+
+ def visit_stat(self, stat):
+ self._writer.element('stat', stat.name, stat.get_attributes())
+
=======================================
--- /src/robot/result/serializer.py Thu Dec 1 03:39:28 2011
+++ /dev/null
@@ -1,49 +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.
-
-from robot.output.xmllogger import XmlLogger
-from robot.result.visitor import ResultVisitor
-
-
-class RebotXMLWriter(XmlLogger, ResultVisitor):
-
- def __init__(self, output):
- XmlLogger.__init__(self, output, generator='Rebot')
-
- def start_message(self, msg):
- self._write_message(msg)
-
- def close(self):
- self._writer.end('robot')
- self._writer.close()
-
- def start_errors(self, errors):
- XmlLogger.start_errors(self)
-
- def end_errors(self, errors):
- XmlLogger.end_errors(self)
-
- def end_result(self, result):
- self.close()
-
- start_total_statistics = XmlLogger.start_total_stats
- start_tag_statistics = XmlLogger.start_tag_stats
- start_suite_statistics = XmlLogger.start_suite_stats
- end_total_statistics = XmlLogger.end_total_stats
- end_tag_statistics = XmlLogger.end_tag_stats
- end_suite_statistics = XmlLogger.end_suite_stats
-
- def visit_stat(self, stat):
- self._writer.element('stat', stat.name, stat.get_attributes())
-
=======================================
--- /src/robot/reporting/builders.py Tue Dec 13 14:31:37 2011
+++ /src/robot/reporting/builders.py Wed Dec 14 00:37:51 2011
@@ -19,8 +19,7 @@
from robot.errors import DataError
from robot.output import LOGGER
-from robot.result.serializer import RebotXMLWriter
-from robot import utils
+from robot.result.outputwriter import OutputWriter
from .jswriter import SplitLogWriter
from .xunitwriter import XUnitWriter
@@ -34,7 +33,7 @@
def build(self, path):
try:
- writer = RebotXMLWriter(path)
+ writer = OutputWriter(path)
except DataError, err:
LOGGER.error(unicode(err))
else:
=======================================
--- /src/robot/reporting/resultwriter.py Wed Dec 7 07:44:16 2011
+++ /src/robot/reporting/resultwriter.py Wed Dec 14 00:37:51 2011
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
from robot.errors import DATA_ERROR
from robot.reporting.jsmodelbuilders import JsModelBuilder
from robot.result import ResultFromXml
=======================================
--- /utest/result/test_resultserializer.py Thu Dec 1 12:40:32 2011
+++ /utest/result/test_resultserializer.py Wed Dec 14 00:37:51 2011
@@ -5,7 +5,7 @@
from xml.etree.ElementTree import tostring
from robot.result import ResultFromXml
-from robot.result.serializer import RebotXMLWriter
+from robot.result.outputwriter import OutputWriter
from robot.utils.pyxmlwriter import XmlWriter
from robot.utils.asserts import assert_equals
@@ -58,7 +58,7 @@
return value
-class TestableRebotXmlWriter(RebotXMLWriter):
+class TestableOutputWriter(OutputWriter):
def _get_writer(self, output, generator):
writer = StreamXmlWriter(output)
@@ -69,7 +69,7 @@
class TestResultSerializer(unittest.TestCase):
def _create_writer(self, output):
- return TestableRebotXmlWriter(output)
+ return TestableOutputWriter(output)
def test_single_result_serialization(self):
output = StringIO()
==============================================================================
Revision: 6860dc3a145a
Author: Pekka Klärck
Date: Wed Dec 14 01:39:40 2011
Log: Fixed XmlWriter tests on Jython < 2.5.2 on Windows.
http://code.google.com/p/robotframework/source/detail?r=6860dc3a145a
Modified:
/utest/utils/test_xmlwriter.py
=======================================
--- /utest/utils/test_xmlwriter.py Tue Dec 13 13:52:33 2011
+++ /utest/utils/test_xmlwriter.py Wed Dec 14 01:39:40 2011
@@ -1,8 +1,9 @@
+from __future__ import with_statement
import os
import unittest
import tempfile
-from robot import utils
+from robot.utils import XmlWriter, ET, ETSource
from robot.utils.asserts import *
PATH = os.path.join(tempfile.gettempdir(), 'test_xmlwriter.xml')
@@ -11,7 +12,7 @@
class TestXmlWriter(unittest.TestCase):
def setUp(self):
- self.writer = utils.XmlWriter(PATH)
+ self.writer = XmlWriter(PATH)
def tearDown(self):
self.writer.close()
@@ -49,7 +50,8 @@
self.writer.element('child2', attributes={'class': 'foo'})
self.writer.end('root')
self.writer.close()
- root = utils.ET.parse(PATH).getroot()
+ with ETSource(PATH) as source:
+ root = ET.parse(source).getroot()
self._verify_node(root, 'root', attrs={'version': 'test'})
self._verify_node(root.find('child1'), 'child1',
attrs={'my-attr': 'my value'})
self._verify_node(root.find('child1/leaf1.1'), 'leaf1.1',
@@ -68,9 +70,8 @@
self.writer.end('suite')
self.writer.end('root')
self.writer.close()
- f = open(PATH)
- lines = [ line for line in f.readlines() if line != '\n' ]
- f.close()
+ with open(PATH) as file:
+ lines = [line for line in file if line != '\n']
assert_equal(len(lines), 6)
def test_none_content(self):
@@ -94,7 +95,8 @@
self.writer.element(u'f', u'Hyv\u00E4\u00E4 \u00FC\u00F6t\u00E4')
self.writer.end('root')
self.writer.close()
- root = utils.ET.parse(PATH).getroot()
+ with ETSource(PATH) as source:
+ root = ET.parse(source).getroot()
self._verify_node(root.find('e'), 'e', u'Circle is 360\u00B0')
self._verify_node(root.find('f'), 'f',
u'Hyv\u00E4\u00E4 \u00FC\u00F6t\u00E4')
@@ -102,21 +104,21 @@
def test_content_with_entities(self):
self.writer.element(u'robot-log', 'Me, Myself & I > you')
self.writer.close()
- f = open(PATH)
- content = f.read()
- f.close()
- assert_true(content.count('Me, Myself & I > you') > 0)
+ with open(PATH) as file:
+ content = file.read()
+ assert_true('Me, Myself & I > you' in content)
def test_remove_illegal_chars(self):
assert_equals(self.writer._escape(u'\x1b[31m'), '[31m')
assert_equals(self.writer._escape(u'\x00'), '')
def test_ioerror_when_file_is_invalid(self):
- assert_raises(IOError, utils.XmlWriter, os.path.dirname(__file__))
+ assert_raises(IOError, XmlWriter, os.path.dirname(__file__))
def _verify_node(self, node, name, text=None, attrs={}):
if node is None:
- node = utils.ET.parse(PATH).getroot()
+ with ETSource(PATH) as source:
+ node = ET.parse(source).getroot()
assert_equals(node.tag, name)
if text is not None:
assert_equals(node.text, text)
==============================================================================
Revision: 77c31508bea6
Author: Pekka Klärck
Date: Wed Dec 14 01:41:20 2011
Log: Small XmlWriter enhancements
http://code.google.com/p/robotframework/source/detail?r=77c31508bea6
Modified:
/src/robot/utils/abstractxmlwriter.py
/src/robot/utils/jyxmlwriter.py
=======================================
--- /src/robot/utils/abstractxmlwriter.py Tue Dec 6 04:14:37 2011
+++ /src/robot/utils/abstractxmlwriter.py Wed Dec 14 01:41:20 2011
@@ -57,8 +57,9 @@
self.end(name, newline)
def close(self):
- self._close()
- self.closed = True
+ if not self.closed:
+ self._close()
+ self.closed = True
def _close(self):
self._writer.endDocument()
=======================================
--- /src/robot/utils/jyxmlwriter.py Tue Dec 13 13:52:33 2011
+++ /src/robot/utils/jyxmlwriter.py Wed Dec 14 01:41:20 2011
@@ -37,7 +37,7 @@
try:
return FileOutputStream(output)
except FileNotFoundException, err:
- raise IOError(None, err.getMessage(), output)
+ raise IOError(-1, err.getMessage(), output)
def _start(self, name, attrs):
self._writer.startElement('', '', name,
self._get_attrs_impl(attrs))
==============================================================================
Revision: 6f27c4dcf507
Author: Pekka Klärck
Date: Wed Dec 14 01:46:23 2011
Log: OutputWriter: Better external API. Internal cleanup still needed
and added TODOs about that.
http://code.google.com/p/robotframework/source/detail?r=6f27c4dcf507
Modified:
/src/robot/reporting/builders.py
/src/robot/result/outputwriter.py
/utest/result/test_resultserializer.py
=======================================
--- /src/robot/reporting/builders.py Wed Dec 14 00:37:51 2011
+++ /src/robot/reporting/builders.py Wed Dec 14 01:46:23 2011
@@ -33,11 +33,10 @@
def build(self, path):
try:
- writer = OutputWriter(path)
+ OutputWriter(self._model).write_to(path)
except DataError, err:
LOGGER.error(unicode(err))
else:
- self._model.visit(writer)
LOGGER.output_file('Output', path)
=======================================
--- /src/robot/result/outputwriter.py Wed Dec 14 00:37:51 2011
+++ /src/robot/result/outputwriter.py Wed Dec 14 01:46:23 2011
@@ -15,11 +15,18 @@
from robot.output.xmllogger import XmlLogger
from robot.result.visitor import ResultVisitor
+# TODO: Unify XmlLogger and ResultVisitor APIs.
+# Perhaps XmlLogger could be ResultVisitor.
+# TODO: Use delegation instead of multi-inheritance
class OutputWriter(XmlLogger, ResultVisitor):
- def __init__(self, output):
- XmlLogger.__init__(self, output, generator='Rebot')
+ def __init__(self, model):
+ self._model = model
+
+ def write_to(self, path):
+ XmlLogger.__init__(self, path, generator='Rebot')
+ self._model.visit(self)
def start_message(self, msg):
self._write_message(msg)
=======================================
--- /utest/result/test_resultserializer.py Wed Dec 14 00:37:51 2011
+++ /utest/result/test_resultserializer.py Wed Dec 14 01:46:23 2011
@@ -68,12 +68,10 @@
class TestResultSerializer(unittest.TestCase):
- def _create_writer(self, output):
- return TestableOutputWriter(output)
-
def test_single_result_serialization(self):
+ writer = TestableOutputWriter(ResultFromXml(GOLDEN_XML))
output = StringIO()
-
ResultFromXml(StringIO(GOLDEN_XML)).visit(self._create_writer(output))
+ writer.write_to(output)
self._assert_xml_content(self._xml_lines(output.getvalue()),
self._xml_lines(GOLDEN_XML))
@@ -86,11 +84,12 @@
assert_equals(act, exp.strip(), 'Different values on
line %d' % index)
def test_combining_results(self):
+ writer = TestableOutputWriter(ResultFromXml(GOLDEN_XML,
GOLDEN_XML))
output = StringIO()
- result = ResultFromXml(StringIO(GOLDEN_XML), StringIO(GOLDEN_XML))
- result.visit(self._create_writer(output))
+ writer.write_to(output)
self._assert_xml_content(self._xml_lines(output.getvalue()),
self._xml_lines(GOLDEN_XML_TWICE))
+
if __name__ == '__main__':
unittest.main()
==============================================================================
Revision: e2a28b513882
Author: Pekka Klärck
Date: Wed Dec 14 01:46:30 2011
Log: Automated merge with https://robotframework.googlecode.com/hg/
http://code.google.com/p/robotframework/source/detail?r=e2a28b513882
Deleted:
/src/robot/result/serializer.py
=======================================
--- /src/robot/result/serializer.py Thu Dec 1 03:39:28 2011
+++ /dev/null
@@ -1,49 +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.
-
-from robot.output.xmllogger import XmlLogger
-from robot.result.visitor import ResultVisitor
-
-
-class RebotXMLWriter(XmlLogger, ResultVisitor):
-
- def __init__(self, output):
- XmlLogger.__init__(self, output, generator='Rebot')
-
- def start_message(self, msg):
- self._write_message(msg)
-
- def close(self):
- self._writer.end('robot')
- self._writer.close()
-
- def start_errors(self, errors):
- XmlLogger.start_errors(self)
-
- def end_errors(self, errors):
- XmlLogger.end_errors(self)
-
- def end_result(self, result):
- self.close()
-
- start_total_statistics = XmlLogger.start_total_stats
- start_tag_statistics = XmlLogger.start_tag_stats
- start_suite_statistics = XmlLogger.start_suite_stats
- end_total_statistics = XmlLogger.end_total_stats
- end_tag_statistics = XmlLogger.end_tag_stats
- end_suite_statistics = XmlLogger.end_suite_stats
-
- def visit_stat(self, stat):
- self._writer.element('stat', stat.name, stat.get_attributes())
-