summaryrefslogtreecommitdiff
path: root/functional_tests/test_xunit.py
diff options
context:
space:
mode:
authorkumar <kumar.mcmillan@gmail.com>2010-12-01 13:25:24 -0600
committerkumar <kumar.mcmillan@gmail.com>2010-12-01 13:25:24 -0600
commit4cc5045553a7fdebd2e7b3d51b2e432c359b6d48 (patch)
tree885b47544b6fb8d7f860772219e459d1f8c6a127 /functional_tests/test_xunit.py
parent3c1a54b1522008823535f50b955cb9d449456739 (diff)
downloadnose-4cc5045553a7fdebd2e7b3d51b2e432c359b6d48.tar.gz
Fixes test code when run in a python 3 that was compiled with ascii encoding as default
Diffstat (limited to 'functional_tests/test_xunit.py')
-rw-r--r--functional_tests/test_xunit.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/functional_tests/test_xunit.py b/functional_tests/test_xunit.py
index 00e16b1..a3bbaff 100644
--- a/functional_tests/test_xunit.py
+++ b/functional_tests/test_xunit.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+import codecs
import os
+import sys
import unittest
from nose.plugins.xunit import Xunit
from nose.plugins.skip import Skip
@@ -25,15 +27,20 @@ class TestXUnitPlugin(PluginTester, unittest.TestCase):
assert "test_skip (test_xunit_as_suite.TestForXunit) ... SKIP: skipit" in self.output
assert "XML: %s" % xml_results_filename in self.output
- f = open(xml_results_filename,'r')
+ f = codecs.open(xml_results_filename,'r', encoding='utf8')
result = f.read()
f.close()
- print result
+ print result.encode('utf8', 'replace')
assert '<?xml version="1.0" encoding="UTF-8"?>' in result
assert '<testsuite name="nosetests" tests="6" errors="2" failures="1" skip="1">' in result
assert '<testcase classname="test_xunit_as_suite.TestForXunit" name="test_error" time="0">' in result
- assert '<error type="%s.Exception" message="日本">' % (Exception.__module__,) in result
+ # TODO(Kumar) think of better x-platform code here that
+ # does not confuse 2to3
+ if sys.version_info[0:2] >= (3,0):
+ assert ('<error type="%s.Exception" message="日本">' % (Exception.__module__,)) in result
+ else:
+ assert ('<error type="%s.Exception" message="日本">' % (Exception.__module__,)).decode('utf8') in result
assert '</testcase>' in result
assert '</testsuite>' in result