def test_add(self): inst = (text.Gettext('pale ', 'foo', 'bar') + text.Gettext('blue', 'foo', 'bar')) assert unicode(inst) == 'pale blue' inst = (text.Gettext('bright ', 'foo', 'bar') + text.Gettext('pale ', 'foo', 'bar') + text.Gettext('blue', 'foo', 'bar')) assert unicode(inst) == 'bright pale blue' inst = text.Gettext('yellow', 'foo', 'bar') + '!' assert unicode(inst) == 'yellow!' inst = '!' + text.Gettext('yellow', 'foo', 'bar') assert unicode(inst) == '!yellow' inst = '!' + ('!' + text.Gettext('yellow', 'foo', 'bar')) assert unicode(inst) == '!!yellow' inst = (text.Gettext('yellow', 'foo', 'bar') + '!') + '!' assert unicode(inst) == 'yellow!!'
def test_format(self): inst = self.klass('{0}', text.Gettext('{color}', 'foo', 'bar'), ']') posargs = ('[', '(') knownargs = {'color': 'red', 'stuff': 'junk'} assert inst.format(*posargs, **knownargs) == '[red]'
def test_unicode(self): inst = self.klass('[', text.Gettext('green', 'foo', 'bar'), 1, ']') assert unicode(inst) == u'[green1]'
def test_mod(self): inst = self.klass('[', text.Gettext('%(color)s', 'foo', 'bar'), ']') assert inst % dict(color='red', stuff='junk') == '[red]'
def test_repr(self): lazytext = text.Gettext('foo', 'bar', 'baz') inst = self.klass(lazytext) assert repr(inst) == "ConcatenatedLazyText([%r])" % lazytext