← Back to team overview

testtools-dev team mailing list archive

[Bug 764170] Re: DocTestMatches error when 'actual' is unicode

 

** Changed in: testtools
       Status: In Progress => Fix Committed

** Changed in: testtools
    Milestone: None => next

-- 
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:
  Fix Committed

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)
  ------------

To manage notifications about this bug go to:
https://bugs.launchpad.net/testtools/+bug/764170/+subscriptions


References