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

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Tests being able to ignore bad filetypes."""
19
19
 
 
20
from io import StringIO
20
21
import os
21
22
 
22
23
from .. import (
23
24
    errors,
24
25
    )
25
 
from ..sixish import (
26
 
    BytesIO,
27
 
    )
28
26
from ..status import show_tree_status
29
27
from . import TestCaseWithTransport
30
28
from .features import (
34
32
 
35
33
def verify_status(tester, tree, value):
36
34
    """Verify the output of show_tree_status"""
37
 
    tof = BytesIO()
 
35
    tof = StringIO()
38
36
    show_tree_status(tree, to_file=tof)
39
37
    tof.seek(0)
40
38
    tester.assertEqual(value, tof.readlines())
50
48
        b = wt.branch
51
49
 
52
50
        files = ['one', 'two', 'three']
53
 
        file_ids = ['one-id', 'two-id', 'three-id']
 
51
        file_ids = [b'one-id', b'two-id', b'three-id']
54
52
        self.build_tree(files)
55
53
        wt.add(files, file_ids)
56
 
        wt.commit("Commit one", rev_id="a@u-0-0")
 
54
        wt.commit("Commit one", rev_id=b"a@u-0-0")
57
55
 
58
56
        # We should now have a few files, lets try to
59
57
        # put some bogus stuff in the tree
65
63
        self.build_tree(['six'])
66
64
 
67
65
        verify_status(self, wt,
68
 
                          ['unknown:\n',
69
 
                           '  a-fifo\n',
70
 
                           '  six\n'
71
 
                           ])
 
66
                      ['unknown:\n',
 
67
                       '  a-fifo\n',
 
68
                       '  six\n'
 
69
                       ])
72
70
 
73
71
        # We should raise an error if we are adding a bogus file
74
72
        self.assertRaises(errors.BadFileKindError, wt.smart_add, ['a-fifo'])
75
73
 
76
74
        # And the list of files shouldn't have been modified
77
75
        verify_status(self, wt,
78
 
                          ['unknown:\n',
79
 
                           '  a-fifo\n',
80
 
                           '  six\n'
81
 
                           ])
 
76
                      ['unknown:\n',
 
77
                       '  a-fifo\n',
 
78
                       '  six\n'
 
79
                       ])
82
80
 
83
81
        # Make sure smart_add can handle having a bogus
84
82
        # file in the way
85
83
        wt.smart_add([])
86
84
        verify_status(self, wt,
87
 
                          ['added:\n',
88
 
                           '  six\n',
89
 
                           'unknown:\n',
90
 
                           '  a-fifo\n',
91
 
                           ])
92
 
        wt.commit("Commit four", rev_id="a@u-0-3")
 
85
                      ['added:\n',
 
86
                       '  six\n',
 
87
                       'unknown:\n',
 
88
                       '  a-fifo\n',
 
89
                       ])
 
90
        wt.commit("Commit four", rev_id=b"a@u-0-3")
93
91
 
94
92
        verify_status(self, wt,
95
 
                          ['unknown:\n',
96
 
                           '  a-fifo\n',
97
 
                           ])
 
93
                      ['unknown:\n',
 
94
                       '  a-fifo\n',
 
95
                       ])