You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by hw...@apache.org on 2010/08/03 18:36:53 UTC
svn commit: r981961 - /labs/mouse/tests/test_mouse.py
Author: hwright
Date: Tue Aug 3 16:36:53 2010
New Revision: 981961
URL: http://svn.apache.org/viewvc?rev=981961&view=rev
Log:
Restructure the Mouse report tests to allow easy adding of additional tests.
Modified:
labs/mouse/tests/test_mouse.py
Modified: labs/mouse/tests/test_mouse.py
URL: http://svn.apache.org/viewvc/labs/mouse/tests/test_mouse.py?rev=981961&r1=981960&r2=981961&view=diff
==============================================================================
--- labs/mouse/tests/test_mouse.py (original)
+++ labs/mouse/tests/test_mouse.py Tue Aug 3 16:36:53 2010
@@ -92,26 +92,34 @@ def _count_items(items):
class TestReport(unittest.TestCase):
'Test generating reports'
- def test_greek_vanilla_xml(self):
- items = sources.get_items(os.path.join(data_path, 'greek'))
+ plain_xsl_path = os.path.join(resources_path, 'plain-rat.xsl')
+ expected_output_path = os.path.join(data_path, 'expected_output')
+
+ def _check_plain_output(self, input_path, expected_output_filename):
+ items = sources.get_items(os.path.join(data_path, input_path))
+ report = mouse.generate_report(items)
+ output = mouse.process_report(report)
+ output = mouse.transform_xslt(output, self.plain_xsl_path)
+ actual = output.split()
+ expected = open(os.path.join(self.expected_output_path,
+ expected_output_filename)).read().split()
+ self.assertEqual(actual, expected)
+
+ def _check_xml_output(self, input_path, expected_output_filename):
+ items = sources.get_items(os.path.join(data_path, input_path))
report = mouse.generate_report(items)
output = mouse.process_report(report)
output_element = ElementTree.XML(output)
- target_xml = open(os.path.join(data_path, 'expected_output',
- 'greek_vanilla.xml')).read()
+ target_xml = open(os.path.join(self.expected_output_path,
+ expected_output_filename)).read()
target_element = ElementTree.XML(target_xml)
self.assertTrue(elements_are_same(output_element, target_element))
+
+ def test_greek_vanilla_xml(self):
+ self._check_xml_output('greek', 'greek_vanilla.xml')
def test_greek_vanilla(self):
- items = sources.get_items(os.path.join(data_path, 'greek'))
- report = mouse.generate_report(items)
- output = mouse.process_report(report)
- output = mouse.transform_xslt(output, os.path.join(resources_path,
- 'plain-rat.xsl'))
- actual = output.split()
- expected = open(os.path.join(data_path, 'expected_output',
- 'greek_vanilla')).read().split()
- self.assertEqual(actual, expected)
+ self._check_plain_output('greek', 'greek_vanilla')
class TestFilters(unittest.TestCase):
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org