/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: 2017-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

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