def test_printf_formats(self): class Language(object): pass sl = Language() sl.nplurals = 2 tl = Language() tl.nplurals = 2 v = PrintfFormatNumberValidator(sl, tl) old = "%s %d" new = "%s %d" v(old, new) new = "%f" self.assertRaises(ValidationError, v, old, new) tl.nplurals = 3 new = "%f %s %x" v(old, new)
def test_singular_printf_number(self): class Language(object): pass sl = Language() sl.nplurals = 2 tl = Language() tl.nplurals = 2 v = PrintfFormatPluralizedNumberValidator(sl, tl, rule=5) old = "%s apples" new = "apples" self.assertRaises(ValidationError, v, old, new) v.rule = 1 new = "apple" v(old, new) v.rule = 5 tl.nplurals = 5 v(old, new)