/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_export_pot.py

  • Committer: INADA Naoki
  • Date: 2011-05-11 17:44:45 UTC
  • mto: (5830.3.4 i18n-msgfmt)
  • mto: This revision was merged to the branch mainline in revision 5873.
  • Revision ID: songofacandy@gmail.com-20110511174445-mujuqv99lf9trlbv
Add test for _poentry_per_peragraph()

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
from cStringIO import StringIO
 
18
import textwrap
18
19
 
19
20
from bzrlib import (
20
21
    export_pot,
62
63
        self.assertEqual(export_pot._normalize(s), e)
63
64
 
64
65
 
65
 
class TestPoEntry(tests.TestCase):
 
66
class PoEntryTestCase(tests.TestCase):
66
67
 
67
68
    def setUp(self):
68
69
        self.overrideAttr(export_pot, '_FOUND_MSGID', set())
69
70
        self._outf = StringIO()
70
 
        super(TestPoEntry, self).setUp()
 
71
        super(PoEntryTestCase, self).setUp()
 
72
 
 
73
    def check_output(self, expected):
 
74
        self.assertEqual(
 
75
                self._outf.getvalue(),
 
76
                textwrap.dedent(expected)
 
77
                )
 
78
 
 
79
class TestPoEntry(PoEntryTestCase):
71
80
 
72
81
    def test_simple(self):
73
 
        export_pot._poentry( self._outf, 'dummy', 1, "spam")
74
 
        export_pot._poentry( self._outf, 'dummy', 2, "ham", 'EGG')
75
 
        self.assertEqual(
76
 
                self._outf.getvalue(),
77
 
                '''#: dummy:1\n'''
78
 
                '''msgid "spam"\n'''
79
 
                '''msgstr ""\n'''
80
 
                '''\n'''
81
 
                '''#: dummy:2\n'''
82
 
                '''# EGG\n'''
83
 
                '''msgid "ham"\n'''
84
 
                '''msgstr ""\n'''
85
 
                '''\n'''
86
 
                )
 
82
        export_pot._poentry(self._outf, 'dummy', 1, "spam")
 
83
        export_pot._poentry(self._outf, 'dummy', 2, "ham", 'EGG')
 
84
        self.check_output('''\
 
85
                #: dummy:1
 
86
                msgid "spam"
 
87
                msgstr ""
 
88
 
 
89
                #: dummy:2
 
90
                # EGG
 
91
                msgid "ham"
 
92
                msgstr ""
 
93
 
 
94
                ''')
87
95
 
88
96
    def test_duplicate(self):
89
97
        export_pot._poentry(self._outf, 'dummy', 1, "spam")
90
98
        # This should be ignored.
91
99
        export_pot._poentry(self._outf, 'dummy', 2, "spam", 'EGG')
92
100
 
93
 
        self.assertEqual(
94
 
                self._outf.getvalue(),
95
 
                '''#: dummy:1\n'''
96
 
                '''msgid "spam"\n'''
97
 
                '''msgstr ""\n'''
98
 
                '''\n'''
99
 
                )
100
 
 
 
101
        self.check_output('''\
 
102
                #: dummy:1
 
103
                msgid "spam"
 
104
                msgstr ""\n
 
105
                ''')
 
106
 
 
107
 
 
108
class TestPoentryPerPergraph(PoEntryTestCase):
 
109
 
 
110
    def test_single(self):
 
111
        export_pot._poentry_per_paragraph(
 
112
                self._outf,
 
113
                'dummy',
 
114
                10,
 
115
                '''foo\nbar\nbaz\n'''
 
116
                )
 
117
        self.check_output('''\
 
118
                #: dummy:10
 
119
                msgid ""
 
120
                "foo\\n"
 
121
                "bar\\n"
 
122
                "baz\\n"
 
123
                msgstr ""\n
 
124
                ''')
 
125
 
 
126
    def test_multi(self):
 
127
        export_pot._poentry_per_paragraph(
 
128
                self._outf,
 
129
                'dummy',
 
130
                10,
 
131
                '''spam\nham\negg\n\nSPAM\nHAM\nEGG\n'''
 
132
                )
 
133
        self.check_output('''\
 
134
                #: dummy:10
 
135
                msgid ""
 
136
                "spam\\n"
 
137
                "ham\\n"
 
138
                "egg"
 
139
                msgstr ""
 
140
 
 
141
                #: dummy:14
 
142
                msgid ""
 
143
                "SPAM\\n"
 
144
                "HAM\\n"
 
145
                "EGG\\n"
 
146
                msgstr ""\n
 
147
                ''')