Comments (8)
Leo,
We changed testtools to error when text_content was passed text, rather than bytes, which I think is what's happening here. Does this still happen with the newest testtools?
Cheers,
from testtools.
ping?
from testtools.
Hello, sorry for the late reply.
With this test I can reproduce it on python2, on ubuntu vivid. It works on python3. I will try it later in a virtualenv with the version from pypi.
# -*- coding: utf-8 -*-
from testtools import TestCase
from testtools.content import text_content
class Test(TestCase):
def test_detail(self):
self.addDetail('arbitrary-text', text_content('ĝ'))
self.fail()
elopio@tangamandapio76:~$ apt-cache policy python-testtools
python-testtools:
Instalita: 0.9.39-1
Kandidato: 0.9.39-1
Version table:
*** 0.9.39-1 0
500 http://cr.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages
100 /var/lib/dpkg/status
elopio@tangamandapio76:~$ python -m unittest discover /tmp/
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/unittest/__main__.py", line 12, in <module>
main(module=None)
File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/usr/lib/python2.7/unittest/main.py", line 232, in runTests
self.result = testRunner.run(self.test)
File "/usr/lib/python2.7/unittest/runner.py", line 151, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/lib/python2.7/unittest/case.py", line 393, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 585, in run
return self.__RunTest(self, self.exception_handlers).run(result)
File "/usr/lib/python2.7/dist-packages/testtools/runtest.py", line 74, in run
return self._run_one(actual_result)
File "/usr/lib/python2.7/dist-packages/testtools/runtest.py", line 88, in _run_one
return self._run_prepared_result(ExtendedToOriginalDecorator(result))
File "/usr/lib/python2.7/dist-packages/testtools/runtest.py", line 107, in _run_prepared_result
handler(self.case, self.result, e)
File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 558, in _report_failure
result.addFailure(self, details=self.getDetails())
File "/usr/lib/python2.7/dist-packages/testtools/testresult/real.py", line 1148, in addFailure
err = self._details_to_exc_info(details)
File "/usr/lib/python2.7/dist-packages/testtools/testresult/real.py", line 1210, in _details_to_exc_info
_StringException(_details_to_str(details, special='traceback')),
File "/usr/lib/python2.7/dist-packages/testtools/testresult/real.py", line 1752, in _details_to_str
text = content.as_text().strip()
File "/usr/lib/python2.7/dist-packages/testtools/content.py", line 94, in as_text
return _u('').join(self.iter_text())
File "/usr/lib/python2.7/dist-packages/testtools/content.py", line 117, in _iter_text
for bytes in self.iter_bytes():
File "/usr/lib/python2.7/dist-packages/testtools/content.py", line 98, in iter_bytes
return self._get_bytes()
File "/usr/lib/python2.7/dist-packages/testtools/content.py", line 269, in <lambda>
return Content(UTF8_TEXT, lambda: [text.encode('utf8')])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in range(128)
elopio@tangamandapio76:~$ apt-cache policy python3-testtools
python3-testtools:
Instalita: 0.9.39-1
Kandidato: 0.9.39-1
Version table:
*** 0.9.39-1 0
500 http://cr.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages
100 /var/lib/dpkg/status
elopio@tangamandapio76:~$ python3 -m unittest discover /tmp/
F
======================================================================
FAIL: test_detail (test.Test)
test.Test.test_detail
----------------------------------------------------------------------
testtools.testresult.real._StringException: arbitrary-text: {{{ĝ}}}
Traceback (most recent call last):
File "/tmp/test.py", line 12, in test_detail
self.fail()
File "/usr/lib/python3.4/unittest/case.py", line 642, in fail
raise self.failureException(msg)
AssertionError: None
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)
from testtools.
Reproduced using the version from pypi, that's 1.8.0: http://paste.ubuntu.com/11794827/
I'm having problems running this from source: http://paste.ubuntu.com/11794827/
It'll have to wait until I have some more time to figure out what am I doing wrong in there.
from testtools.
@ElOpio - your last comment has the same pastebin twice - I guess that's not what you meant to do :D
I have some time to try and reproduce and fix this, but I'm unable to reproduce. I suspect it requires some environment variables to be set: LANG etc.
Are you able to take another look and see if this still happens?
Cheers.
from testtools.
Yeah, I'm not sure what I was trying to say in that repeated paste.
Did you try with this, from my previous comment, on py2?
self.addDetail('arbitrary-text', text_content('ĝ'))
from testtools.
@ElOpio I did, and it works for me in both 2.7.9 and 3.4.3. Like I say, I imagine it depends on certain environment variables - you mention this only started happening when you updated some language settings?
from testtools.
I'm going to close this - another 6 months and no reproducer. please do reopen if you can provide updated instructions on reproducing.
from testtools.
Related Issues (20)
- Please make a new release HOT 2
- Deprecate testtools.distutilscmd?
- `TestCase.subTest` does not isolate tests
- “It is no longer useless …” in NEWS
- Release to support Python 3.10 HOT 1
- Update `doc/description.rst`
- trailing newline in str comparison is hard to spot
- Compatibility with Python 3.11
- The testtools documentation on readthedocs is not up to date. HOT 3
- 2.5.0 + master: sphinx warnings `reference target not found`
- 2.5.0 + master (b68af1b0): pytest is failing HOT 18
- Test failures with PyPy3.9 HOT 2
- deprecation warning on Python 3.11: 'cgi' is deprecated and slated for removal in Python 3.13 HOT 1
- testcase.py __eq__ function throwing an error
- AttributeError: module 'email' has no attribute 'message' HOT 1
- `testtools` fails to import with Python 3.12 HOT 4
- Issue a python3.12 release HOT 1
- 2.7.0 sdist is unusable (builds version "0.0.0")
- Missing dependency on fixtures since 2.7.0 HOT 1
- Pytest 8: AttributeError: 'TestExpectedException' object has no attribute 'runTest'. Did you mean: 'subTest'? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testtools.