274
275
matcher = Contains("bar")
275
276
mismatch = matcher.match("foo")
276
277
self.assertEqual("bar", mismatch.expected)
280
class EqualsIgnoringWhitespaceTests(TestCase):
283
matcher = EqualsIgnoringWhitespace("abc")
284
self.assertEqual("EqualsIgnoringWhitespace('abc')", str(matcher))
286
def test_match_str(self):
287
matcher = EqualsIgnoringWhitespace("one \t two \n three")
288
self.assertIs(None, matcher.match(" one \r two three "))
290
def test_mismatch_str(self):
291
matcher = EqualsIgnoringWhitespace("one \t two \n three")
292
mismatch = matcher.match(" one \r three ")
294
"'one two three' != 'one three'",
297
def test_match_unicode(self):
298
matcher = EqualsIgnoringWhitespace(u"one \t two \n \u1234 ")
299
self.assertIs(None, matcher.match(u" one \r two \u1234 "))
301
def test_mismatch_unicode(self):
302
matcher = EqualsIgnoringWhitespace(u"one \t two \n \u1234 ")
303
mismatch = matcher.match(u" one \r \u1234 ")
305
u"u'one two \\u1234' != u'one \\u1234'",
308
def test_match_non_string(self):
309
matcher = EqualsIgnoringWhitespace(1234)
310
self.assertIs(None, matcher.match(1234))