Package translate :: Package misc :: Module test_multistring

[hide private]
[frames] | no frames]

# Source Code for Module translate.misc.test_multistring

     1  #!/usr/bin/env python
     2
     3  from translate.misc import multistring
     4  from translate.misc import test_autoencode
     5
     6 -class TestMultistring(test_autoencode.TestAutoencode):
     7      type2test = multistring.multistring
     8
     9 -    def test_constructor(self):
    10          t = self.type2test
    11          s1 = t("test")
    12          assert type(s1) == t
    13          assert s1 == "test"
    14          assert s1.strings == ["test"]
    15          s2 = t(["test", "me"])
    16          assert type(s2) == t
    17          assert s2 == "test"
    18          assert s2.strings == ["test", "me"]
    19          assert s2 != s1
    20
    21 -    def test_replace(self):
    22          t = self.type2test
    23          s1 = t(["abcdef", "def"])
    24
    25          result = s1.replace("e", "")
    26          assert type(result) == t
    27          assert result == t(["abcdf", "df"])
    28
    29          result = s1.replace("e", "xx")
    30          assert result == t(["abcdxxf", "dxxf"])
    31
    32          result = s1.replace("e", u"\xe9")
    33          assert result == t([u"abcd\xe9f", u"d\xe9f"])
    34
    35          result = s1.replace("e", "\n")
    36          assert result == t([u"abcd\nf", u"d\nf"])
    37
    38          result = result.replace("\n", "\\n")
    39          assert result == t([u"abcd\\nf", u"d\\nf"])
    40
    41          result = result.replace("\\n", "\n")
    42          assert result == t([u"abcd\nf", u"d\nf"])
    43