~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Patch Queue Manager
  • Date: 2014-09-22 19:42:30 UTC
  • mfrom: (6597.2.1 bzr)
  • Revision ID: pqm@pqm.ubuntu.com-20140922194230-y32j0sq621bxhp7c
(richard-wilbur) Split diff format option parser into a separate function,
 update to include all format options for GNU diff v3.2,
 and test parser.  Fixes lp:1370435 (Richard Wilbur)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2014 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
143
143
                          'old', ['boo\n'], 'new', ['goo\n'],
144
144
                          StringIO(), diff_opts=['-u'])
145
145
 
 
146
    def test_default_style_unified(self):
 
147
        """Check for default style '-u' only if no other style specified
 
148
        in 'diff-options'.
 
149
        """
 
150
        # Verify that style defaults to unified, id est '-u' appended
 
151
        # to option list, in the absence of an alternative style.
 
152
        self.assertEqual(['-a', '-u'], diff.default_style_unified(["-a"]))
 
153
        # Verify that for all valid style options, '-u' is not
 
154
        # appended to option list.
 
155
        for s in diff.style_option_list:
 
156
            ret_opts = diff.default_style_unified(diff_opts=["%s" % (s,)])
 
157
            self.assertEqual(["%s" % (s,)], ret_opts)
 
158
 
146
159
    def test_internal_diff_default(self):
147
160
        # Default internal diff encoding is utf8
148
161
        output = StringIO()
1391
1404
        diff_obj._execute('old', 'new')
1392
1405
        self.assertEqual(output.getvalue().rstrip(), 'old new')
1393
1406
 
1394
 
    def test_excute_missing(self):
 
1407
    def test_execute_missing(self):
1395
1408
        diff_obj = diff.DiffFromTool(['a-tool-which-is-unlikely-to-exist'],
1396
1409
                                     None, None, None)
1397
1410
        self.addCleanup(diff_obj.finish)