/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/test_delta.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import os
18
 
from cStringIO import StringIO
19
18
 
20
 
from bzrlib import (
 
19
from .. import (
21
20
    delta as _mod_delta,
22
21
    revision as _mod_revision,
23
22
    tests,
24
23
    )
 
24
from ..sixish import (
 
25
    BytesIO,
 
26
    )
25
27
 
26
28
 
27
29
class InstrumentedReporter(object):
225
227
class TestChangesFrom(tests.TestCaseWithTransport):
226
228
 
227
229
    def show_string(self, delta, *args,  **kwargs):
228
 
        to_file = StringIO()
 
230
        to_file = BytesIO()
229
231
        _mod_delta.report_delta(to_file, delta, *args, **kwargs)
230
232
        return to_file.getvalue()
231
233
 
319
321
 
320
322
    def test_delta_show_short_status_no_filter(self):
321
323
        d, long_status, short_status = self._get_delta()
322
 
        out = StringIO()
 
324
        out = BytesIO()
323
325
        _mod_delta.report_delta(out, d, short_status=True)
324
326
        self.assertEqual(short_status, out.getvalue())
325
327
 
326
328
    def test_delta_show_long_status_no_filter(self):
327
329
        d, long_status, short_status = self._get_delta()
328
 
        out = StringIO()
 
330
        out = BytesIO()
329
331
        _mod_delta.report_delta(out, d, short_status=False)
330
332
        self.assertEqual(long_status, out.getvalue())
331
333
 
332
334
    def test_delta_show_no_filter(self):
333
335
        d, long_status, short_status = self._get_delta()
334
 
        out = StringIO()
 
336
        out = BytesIO()
335
337
        def not_a_filter(path, file_id):
336
338
            return True
337
339
        _mod_delta.report_delta(out, d, short_status=True, filter=not_a_filter)
339
341
 
340
342
    def test_delta_show_short_status_single_file_filter(self):
341
343
        d, long_status, short_status = self._get_delta()
342
 
        out = StringIO()
 
344
        out = BytesIO()
343
345
        def only_f2(path, file_id):
344
346
            return path == 'f2'
345
347
        _mod_delta.report_delta(out, d, short_status=True, filter=only_f2)
347
349
 
348
350
    def test_delta_show_long_status_single_file_filter(self):
349
351
        d, long_status, short_status = self._get_delta()
350
 
        out = StringIO()
 
352
        out = BytesIO()
351
353
        def only_f2(path, file_id):
352
354
            return path == 'f2'
353
355
        _mod_delta.report_delta(out, d, short_status=False, filter=only_f2)
355
357
 
356
358
    def test_delta_show_short_status_single_file_id_filter(self):
357
359
        d, long_status, short_status = self._get_delta()
358
 
        out = StringIO()
 
360
        out = BytesIO()
359
361
        def only_f2_id(path, file_id):
360
362
            return file_id == 'f2-id'
361
363
        _mod_delta.report_delta(out, d, short_status=True, filter=only_f2_id)