testtools-dev team mailing list archive
-
testtools-dev team
-
Mailing list archive
-
Message #00626
[Bug 764170] [NEW] DocTestMatches error when 'actual' is unicode
Public bug reported:
When TestCase.assertThat is invoked with a unicode string and a
DocTestMatches instance, the _with_nl() call made by the
DocTestMatches.match() method fails if the argument 'actual' is a
unicode string.
class MyTestCase(TestCase)
def myTest(self):
foo = u"foo\u2026"
self.assertThat(foo, DocTestMatches(foo))
Trackback:
File "/home/ian/projects/lp-sourcedeps/eggs/testtools-0.9.10-py2.6.egg/testtools/testcase.py", line 341, in assertThat
mismatch = matcher.match(matchee)
File "/home/ian/projects/lp-sourcedeps/eggs/testtools-0.9.10-py2.6.egg/testtools/matchers.py", line 175, in match
with_nl = self._with_nl(actual)
File "/home/ian/projects/lp-sourcedeps/eggs/testtools-0.9.10-py2.6.egg/testtools/matchers.py", line 169, in _with_nl
result = str(actual)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 3: ordinal not in range(128)
------------
** Affects: testtools
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of testtools
developers, which is subscribed to testtools.
https://bugs.launchpad.net/bugs/764170
Title:
DocTestMatches error when 'actual' is unicode
Status in testtools:
New
Bug description:
When TestCase.assertThat is invoked with a unicode string and a
DocTestMatches instance, the _with_nl() call made by the
DocTestMatches.match() method fails if the argument 'actual' is a
unicode string.
class MyTestCase(TestCase)
def myTest(self):
foo = u"foo\u2026"
self.assertThat(foo, DocTestMatches(foo))
Trackback:
File "/home/ian/projects/lp-sourcedeps/eggs/testtools-0.9.10-py2.6.egg/testtools/testcase.py", line 341, in assertThat
mismatch = matcher.match(matchee)
File "/home/ian/projects/lp-sourcedeps/eggs/testtools-0.9.10-py2.6.egg/testtools/matchers.py", line 175, in match
with_nl = self._with_nl(actual)
File "/home/ian/projects/lp-sourcedeps/eggs/testtools-0.9.10-py2.6.egg/testtools/matchers.py", line 169, in _with_nl
result = str(actual)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 3: ordinal not in range(128)
------------
Follow ups
References