/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 breezy/tests/test_export_pot.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-06 01:18:08 UTC
  • mfrom: (7143 work)
  • mto: This revision was merged to the branch mainline in revision 7151.
  • Revision ID: jelmer@jelmer.uk-20181106011808-y870f4vq0ork3ahu
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import re
18
18
import textwrap
19
19
 
 
20
from io import StringIO
 
21
 
20
22
from .. import (
21
23
    commands,
22
24
    export_pot,
24
26
    registry,
25
27
    tests,
26
28
    )
27
 
from ..sixish import (
28
 
    BytesIO,
29
 
    )
30
29
 
31
30
 
32
31
class TestEscape(tests.TestCase):
221
220
        self.check_context(context2A, path, 4)
222
221
        context2B = context1.from_string("not there")
223
222
        self.check_context(context2B, path, 21)
224
 
        self.assertContainsRe(self.get_log(), "String 'not there' not found")
 
223
        self.assertContainsRe(self.get_log(), "String b?'not there' not found")
225
224
 
226
225
 
227
226
class TestWriteOption(tests.TestCase):
228
227
    """Tests for writing texts extracted from options in pot format"""
229
228
 
230
229
    def pot_from_option(self, opt, context=None, note="test"):
231
 
        sio = BytesIO()
 
230
        sio = StringIO()
232
231
        exporter = export_pot._PotExporter(sio)
233
232
        if context is None:
234
233
            context = export_pot._ModuleContext("nowhere", 0)
247
246
 
248
247
    def test_option_hidden(self):
249
248
        opt = option.Option("hidden", help="Unseen.", hidden=True)
250
 
        self.assertEqual(b"", self.pot_from_option(opt))
 
249
        self.assertEqual("", self.pot_from_option(opt))
251
250
 
252
251
    def test_option_context_missing(self):
253
252
        context = export_pot._ModuleContext("remote.py", 3)
328
327
 
329
328
    # This test duplicates test_duplicates below
330
329
    def test_duplicates(self):
331
 
        exporter = export_pot._PotExporter(BytesIO())
 
330
        exporter = export_pot._PotExporter(StringIO())
332
331
        context = export_pot._ModuleContext("mod.py", 1)
333
332
        exporter.poentry_in_context(context, "Common line.")
334
333
        context.lineno = 3
335
334
        exporter.poentry_in_context(context, "Common line.")
336
335
        self.assertEqual(1, exporter.outf.getvalue().count("Common line."))
337
 
    
 
336
 
338
337
    def test_duplicates_included(self):
339
 
        exporter = export_pot._PotExporter(BytesIO(), True)
 
338
        exporter = export_pot._PotExporter(StringIO(), True)
340
339
        context = export_pot._ModuleContext("mod.py", 1)
341
340
        exporter.poentry_in_context(context, "Common line.")
342
341
        context.lineno = 3
348
347
 
349
348
    def setUp(self):
350
349
        super(PoEntryTestCase, self).setUp()
351
 
        self.exporter = export_pot._PotExporter(BytesIO())
 
350
        self.exporter = export_pot._PotExporter(StringIO())
352
351
 
353
352
    def check_output(self, expected):
354
353
        self.assertEqual(