Commit bb002275 authored by Stefan Behnel's avatar Stefan Behnel

Add some safety fixes and clean up Py2 test-helper in test_fstring.pyx.

parent f29ef5b5
...@@ -55,10 +55,10 @@ class TestCase(CythonTest): ...@@ -55,10 +55,10 @@ class TestCase(CythonTest):
def assertEqual(self, first, second, msg=None): def assertEqual(self, first, second, msg=None):
# strip u'' string prefixes in Py2 # strip u'' string prefixes in Py2
if first != second and isinstance(first, unicode): if first != second and isinstance(first, unicode):
stripped_first = first.replace("u'", "'").replace('u"', '"') stripped_first = first.replace(u"u'", u"'").replace(u'u"', u'"')
if stripped_first == second: if stripped_first == second:
first = stripped_first first = stripped_first
elif stripped_first.decode('unicode_escape') == second: elif u'\\' in stripped_first and stripped_first.decode('unicode_escape') == second:
first = stripped_first.decode('unicode_escape') first = stripped_first.decode('unicode_escape')
super(TestCase, self).assertEqual(first, second, msg) super(TestCase, self).assertEqual(first, second, msg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment