/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_xml.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 20:02:36 UTC
  • mto: (7490.7.7 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200322200236-fsbl91ktcn6fcbdd
Fix tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from io import BytesIO
18
17
 
19
 
from ... import (
 
18
from .. import (
20
19
    errors,
21
20
    fifo_cache,
22
21
    )
23
 
from .. import (
 
22
from ..bzr import (
24
23
    inventory,
25
 
    serializer,
26
24
    xml6,
27
25
    xml7,
28
26
    xml8,
29
27
    )
30
 
from ..inventory import Inventory
 
28
from ..sixish import (
 
29
    BytesIO,
 
30
    text_type,
 
31
    )
 
32
from ..bzr.inventory import Inventory
31
33
from . import TestCase
32
34
import breezy.bzr.xml5
33
35
 
407
409
        """Can't accidentally open a file with wrong serializer"""
408
410
        s_v6 = breezy.bzr.xml6.serializer_v6
409
411
        s_v7 = xml7.serializer_v7
410
 
        self.assertRaises(serializer.UnexpectedInventoryFormat,
 
412
        self.assertRaises(errors.UnexpectedInventoryFormat,
411
413
                          s_v7.read_inventory_from_lines,
412
414
                          breezy.osutils.split_lines(_expected_inv_v5))
413
 
        self.assertRaises(serializer.UnexpectedInventoryFormat,
 
415
        self.assertRaises(errors.UnexpectedInventoryFormat,
414
416
                          s_v6.read_inventory_from_lines,
415
417
                          breezy.osutils.split_lines(_expected_inv_v7))
416
418
 
422
424
        inv.root.revision = b'root-rev'
423
425
        inv.add(inventory.TreeReference(b'nested-id', 'nested', b'tree-root-321',
424
426
                                        b'rev-outer', b'rev-inner'))
425
 
        self.assertRaises(serializer.UnsupportedInventoryKind,
 
427
        self.assertRaises(errors.UnsupportedInventoryKind,
426
428
                          s_v5.write_inventory_to_lines, inv)
427
 
        self.assertRaises(serializer.UnsupportedInventoryKind,
 
429
        self.assertRaises(errors.UnsupportedInventoryKind,
428
430
                          s_v6.write_inventory_to_lines, inv)
429
431
        lines = s_v7.write_inventory_to_chunks(inv)
430
432
        inv2 = s_v7.read_inventory_from_lines(lines)
489
491
        for parent_id in rev.parent_ids:
490
492
            self.assertIsInstance(parent_id, bytes)
491
493
        self.assertEqual(u'Include \xb5nicode characters\n', rev.message)
492
 
        self.assertIsInstance(rev.message, str)
 
494
        self.assertIsInstance(rev.message, text_type)
493
495
 
494
496
        # ie.revision should either be None or a utf-8 revision id
495
497
        inv = s_v5.read_inventory_from_lines(breezy.osutils.split_lines(_inventory_utf8_v5))
511
513
        for ((exp_path, exp_file_id, exp_parent_id, exp_rev_id),
512
514
             (act_path, act_ie)) in zip(expected, actual):
513
515
            self.assertEqual(exp_path, act_path)
514
 
            self.assertIsInstance(act_path, str)
 
516
            self.assertIsInstance(act_path, text_type)
515
517
            self.assertEqual(exp_file_id, act_ie.file_id)
516
518
            self.assertIsInstance(act_ie.file_id, bytes)
517
519
            self.assertEqual(exp_parent_id, act_ie.parent_id)
526
528
    def test_serialization_error(self):
527
529
        s_v5 = breezy.bzr.xml5.serializer_v5
528
530
        e = self.assertRaises(
529
 
            serializer.UnexpectedInventoryFormat,
 
531
            errors.UnexpectedInventoryFormat,
530
532
            s_v5.read_inventory_from_lines, [b"<Notquitexml"])
531
533
        self.assertEqual(str(e), "unclosed token: line 1, column 0")
532
534