Giter VIP home page Giter VIP logo

Comments (8)

thomir avatar thomir commented on August 21, 2024

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.

rbtcollins avatar rbtcollins commented on August 21, 2024

ping?

from testtools.

come-maiz avatar come-maiz commented on August 21, 2024

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.

come-maiz avatar come-maiz commented on August 21, 2024

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.

thomir avatar thomir commented on August 21, 2024

@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.

come-maiz avatar come-maiz commented on August 21, 2024

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.

thomir avatar thomir commented on August 21, 2024

@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.

rbtcollins avatar rbtcollins commented on August 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.