~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_export_pot.py

  • Committer: Martin Packman
  • Date: 2011-11-21 13:00:48 UTC
  • mto: This revision was merged to the branch mainline in revision 6288.
  • Revision ID: martin.packman@canonical.com-20111121130048-tnw5gyty1b59qrpn
Add export_pot._PotExporter class to avoid module global, and other minor cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
class PoEntryTestCase(tests.TestCase):
71
71
 
72
72
    def setUp(self):
73
 
        self.overrideAttr(export_pot, '_FOUND_MSGID', set())
74
 
        self._outf = StringIO()
75
73
        super(PoEntryTestCase, self).setUp()
 
74
        self.exporter = export_pot._PotExporter(StringIO())
76
75
 
77
76
    def check_output(self, expected):
78
77
        self.assertEqual(
79
 
                self._outf.getvalue(),
 
78
                self.exporter.outf.getvalue(),
80
79
                textwrap.dedent(expected)
81
80
                )
82
81
 
83
82
class TestPoEntry(PoEntryTestCase):
84
83
 
85
84
    def test_simple(self):
86
 
        export_pot._poentry(self._outf, 'dummy', 1, "spam")
87
 
        export_pot._poentry(self._outf, 'dummy', 2, "ham", 'EGG')
 
85
        self.exporter.poentry('dummy', 1, "spam")
 
86
        self.exporter.poentry('dummy', 2, "ham", 'EGG')
88
87
        self.check_output('''\
89
88
                #: dummy:1
90
89
                msgid "spam"
98
97
                ''')
99
98
 
100
99
    def test_duplicate(self):
101
 
        export_pot._poentry(self._outf, 'dummy', 1, "spam")
 
100
        self.exporter.poentry('dummy', 1, "spam")
102
101
        # This should be ignored.
103
 
        export_pot._poentry(self._outf, 'dummy', 2, "spam", 'EGG')
 
102
        self.exporter.poentry('dummy', 2, "spam", 'EGG')
104
103
 
105
104
        self.check_output('''\
106
105
                #: dummy:1
112
111
class TestPoentryPerPergraph(PoEntryTestCase):
113
112
 
114
113
    def test_single(self):
115
 
        export_pot._poentry_per_paragraph(
116
 
                self._outf,
 
114
        self.exporter.poentry_per_paragraph(
117
115
                'dummy',
118
116
                10,
119
117
                '''foo\nbar\nbaz\n'''
128
126
                ''')
129
127
 
130
128
    def test_multi(self):
131
 
        export_pot._poentry_per_paragraph(
132
 
                self._outf,
 
129
        self.exporter.poentry_per_paragraph(
133
130
                'dummy',
134
131
                10,
135
132
                '''spam\nham\negg\n\nSPAM\nHAM\nEGG\n'''
169
166
            Blah Blah Blah
170
167
            """
171
168
 
172
 
        export_pot._write_command_help(self._outf, cmd_Demo())
173
 
        result = self._outf.getvalue()
 
169
        export_pot._write_command_help(self.exporter, cmd_Demo())
 
170
        result = self.exporter.outf.getvalue()
174
171
        # We don't care about filename and lineno here.
175
172
        result = re.sub(r'(?m)^#: [^\n]+\n', '', result)
176
173