Example #1
0
    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!!'
Example #2
0
 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]'
Example #3
0
 def test_unicode(self):
     inst = self.klass('[', text.Gettext('green', 'foo', 'bar'), 1, ']')
     assert unicode(inst) == u'[green1]'
Example #4
0
 def test_mod(self):
     inst = self.klass('[', text.Gettext('%(color)s', 'foo', 'bar'), ']')
     assert inst % dict(color='red', stuff='junk') == '[red]'
Example #5
0
 def test_repr(self):
     lazytext = text.Gettext('foo', 'bar', 'baz')
     inst = self.klass(lazytext)
     assert repr(inst) == "ConcatenatedLazyText([%r])" % lazytext