From 6b8fb41b69b58bdbe639e324e45803ecdb169726 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Sun, 25 Mar 2012 15:48:46 +0100 Subject: Test for csv output. --- python/subunit/tests/test_test_results.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/subunit/tests/test_test_results.py b/python/subunit/tests/test_test_results.py index 36ef15d..f3f3480 100644 --- a/python/subunit/tests/test_test_results.py +++ b/python/subunit/tests/test_test_results.py @@ -14,11 +14,13 @@ # limitations under that license. # +import csv import datetime import sys import unittest from testtools import TestCase +from testtools.compat import StringIO from testtools.content import ( text_content, TracebackContent, @@ -452,7 +454,26 @@ class TestByTestResultTests(testtools.TestCase): ], self.log) -# XXX: Tests for csv_result + +class TestCsvResult(testtools.TestCase): + + def test_csv_output(self): + stream = StringIO() + result = subunit.test_results.csv_result(stream) + result._now = iter(range(5)).next + result.startTestRun() + result.startTest(self) + result.addSuccess(self) + result.stopTest(self) + result.stopTestRun() + stream.seek(0) + reader = csv.reader(stream) + output = list(reader) + self.assertEqual( + [['test', 'status', 'start_time', 'stop_time'], + [self.id(), 'success', '0', '1'], + ], + output) # XXX: Tests for subunit2csv -- cgit v1.2.1