summaryrefslogtreecommitdiff
path: root/unit_tests
diff options
context:
space:
mode:
authorPrabhu Ramachandran <prabhu@aero.iitb.ac.in>2015-08-27 01:39:16 +0530
committerPrabhu Ramachandran <prabhu@aero.iitb.ac.in>2015-08-27 01:39:16 +0530
commit14cbbc3f6d282d9c48bb3d6aa8c048be124780ab (patch)
tree619150a12ec5dfbded839db6fabd39c2f56a6a2f /unit_tests
parent716d822d43db30195f795daa9fd71d54e682ec0c (diff)
downloadnose-14cbbc3f6d282d9c48bb3d6aa8c048be124780ab.tar.gz
BUG: Tee doesn't have encoding or errors attrs.
On Python3, distutils.log uses the encoding and errors attribute of sys.stdout and stderr. Tests error out when nose is run with xunit and it replaces the stdout/stderr with a Tee.
Diffstat (limited to 'unit_tests')
-rw-r--r--unit_tests/test_xunit.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/unit_tests/test_xunit.py b/unit_tests/test_xunit.py
index d98ccba..ba839e1 100644
--- a/unit_tests/test_xunit.py
+++ b/unit_tests/test_xunit.py
@@ -8,7 +8,7 @@ from xml.sax import saxutils
from nose.pyversion import UNICODE_STRINGS
from nose.tools import eq_
-from nose.plugins.xunit import Xunit, escape_cdata, id_split
+from nose.plugins.xunit import Xunit, escape_cdata, id_split, Tee
from nose.exc import SkipTest
from nose.config import Config
@@ -67,11 +67,29 @@ class TestOptions(unittest.TestCase):
(options, args) = parser.parse_args(["--xunit-file=blagojevich.xml"])
eq_(options.xunit_file, "blagojevich.xml")
+class TestTee(unittest.TestCase):
+ def setUp(self):
+ self.orig_stderr = sys.stderr
+ sys.stderr = Tee('utf-8', self.orig_stderr)
+
+ def tearDown(self):
+ sys.stderr = self.orig_stderr
+
+ def test_tee_has_error_and_encoding_attributes(self):
+ tee = Tee('utf-8', sys.stdout)
+ self.assertTrue(hasattr(tee, 'encoding'))
+ self.assertTrue(hasattr(tee, 'errors'))
+
+ def test_tee_works_with_distutils_log(self):
+ from distutils.log import Log, DEBUG
+ l = Log(DEBUG)
+ l.warn('Test')
+
class TestXMLOutputWithXML(unittest.TestCase):
def setUp(self):
self.xmlfile = os.path.abspath(
- os.path.join(os.path.dirname(__file__),
+ os.path.join(os.path.dirname(__file__),
'support', 'xunit.xml'))
parser = optparse.OptionParser()
self.x = Xunit()
@@ -215,7 +233,7 @@ class TestXMLOutputWithXML(unittest.TestCase):
test = mktest()
self.x.beforeTest(test)
try:
- raise RuntimeError(chr(128)) # cannot encode as utf8
+ raise RuntimeError(chr(128)) # cannot encode as utf8
except RuntimeError:
some_err = sys.exc_info()
self.x.addError(test, some_err)
@@ -309,4 +327,3 @@ class TestXMLOutputWithXML(unittest.TestCase):
assert '<?xml version="1.0" encoding="UTF-8"?>' in result
assert ('<testcase classname="test_xunit.TC" '
'name="runTest" time="0') in result
-