-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnicodeDecodeError at _run_module_as_main #97
Comments
Well, that means your stdout had non-ascii written to it in the test; I suspect that that indicates a bug in the stdout capturing logic - disabling the stdout capturing should confirm this by avoiding the error. |
OK, with stdout capturing switched off I have a little bit shorter traceback, but still:
|
Wouldn’t some check here https://hg.python.org/unittest2/file/tip/unittest2/result.py#l180 (or somewhere in the neighborhood; BTW, why is unittest2 not on GitHub?) making sure that all content of |
Hmm, I don't understand, I suppose. I tried to create this test case: matej@mitmanek: unittest2 (test_fail *%)$ git diff master
diff --git a/unittest2/test/test_result.py b/unittest2/test/test_result.py
index a12e7b5..eeb873a 100644
--- a/unittest2/test/test_result.py
+++ b/unittest2/test/test_result.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import sys
import textwrap
import traceback2 as traceback
@@ -261,6 +262,30 @@ class Test_TestResult(unittest2.TestCase):
test_case, formatted_exc = result.errors[0]
self.assertEqual('A tracebacklocals', formatted_exc)
+ def test_addError_locals_unicode(self):
+ class Foo(unittest.TestCase):
+ def test_1(self):
+ raise Exception(u'ошибка случилось')
+
+ def test_2(self):
+ raise Exception('ошибка случилось')
+
+ test_1 = Foo('test_1')
+ test_2 = Foo('test_2')
+ result = unittest.TestResult()
+ result.tb_locals = True
+
+ unittest.result.traceback = MockTraceback
+ self.addCleanup(restore_traceback)
+ result.startTestRun()
+ test_1.run(result)
+ test_2.run(result)
+ result.stopTestRun()
+
+ self.assertEqual(len(result.errors), 2)
+ test_case, formatted_exc = result.errors[0]
+ self.assertEqual('A tracebacklocals', formatted_exc)
+
def test_addSubTest(self):
log = []
class Foo(unittest.TestCase):
matej@mitmanek: unittest2 (test_fail *%)$ And to my surprise it doesn't fail. Why? |
Running a test (using python-unittest2-1.1.0-4 on RHEL-7 with python-2.7.5-34) I end with this mysterious error. I don't even know where to start debugging the problem (there is no hint in the preceding text of any problem):
Any thoughts what should I do? Which debugging logs or something could help you to diagnose this issue, please?
The text was updated successfully, but these errors were encountered: