~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/tests/test_matchers.py

[r=julian-edwards][bug=793620] Show a message on
 DistroSeries:+initseries, and prevent attempts to use the page,
 when the distroseries is in the process of being initialized or when the
 distroseries has already been initialized.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    DoesNotContain,
30
30
    DoesNotCorrectlyProvide,
31
31
    DoesNotProvide,
 
32
    EqualsIgnoringWhitespace,
32
33
    HasQueryCount,
33
34
    IsNotProxied,
34
35
    IsProxied,
274
275
        matcher = Contains("bar")
275
276
        mismatch = matcher.match("foo")
276
277
        self.assertEqual("bar", mismatch.expected)
 
278
 
 
279
 
 
280
class EqualsIgnoringWhitespaceTests(TestCase):
 
281
 
 
282
    def test_str(self):
 
283
        matcher = EqualsIgnoringWhitespace("abc")
 
284
        self.assertEqual("EqualsIgnoringWhitespace('abc')", str(matcher))
 
285
 
 
286
    def test_match_str(self):
 
287
        matcher = EqualsIgnoringWhitespace("one \t two \n three")
 
288
        self.assertIs(None, matcher.match(" one \r two     three "))
 
289
 
 
290
    def test_mismatch_str(self):
 
291
        matcher = EqualsIgnoringWhitespace("one \t two \n three")
 
292
        mismatch = matcher.match(" one \r three ")
 
293
        self.assertEqual(
 
294
            "'one two three' != 'one three'",
 
295
            mismatch.describe())
 
296
 
 
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 "))
 
300
 
 
301
    def test_mismatch_unicode(self):
 
302
        matcher = EqualsIgnoringWhitespace(u"one \t two \n \u1234  ")
 
303
        mismatch = matcher.match(u" one \r \u1234 ")
 
304
        self.assertEqual(
 
305
            u"u'one two \\u1234' != u'one \\u1234'",
 
306
            mismatch.describe())
 
307
 
 
308
    def test_match_non_string(self):
 
309
        matcher = EqualsIgnoringWhitespace(1234)
 
310
        self.assertIs(None, matcher.match(1234))