~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Aaron Bentley
  • Date: 2007-02-06 14:52:16 UTC
  • mfrom: (2266 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2268.
  • Revision ID: abentley@panoramicfeedback.com-20070206145216-fcpi8o3ufvuzwbp9
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Development Ltd
 
1
# Copyright (C) 2005, 2006 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
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
112
112
 
113
113
    def test_external_diff_binary_lang_c(self):
114
114
        orig_lang = os.environ.get('LANG')
 
115
        orig_lc_all = os.environ.get('LC_ALL')
115
116
        try:
116
117
            os.environ['LANG'] = 'C'
 
118
            os.environ['LC_ALL'] = 'C'
117
119
            lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
118
120
            # Older versions of diffutils say "Binary files", newer
119
121
            # versions just say "Files".
121
123
                                  '(Binary f|F)iles old and new differ\n')
122
124
            self.assertEquals(lines[1:], ['\n'])
123
125
        finally:
124
 
            if orig_lang is None:
125
 
                del os.environ['LANG']
126
 
            else:
127
 
                os.environ['LANG'] = orig_lang
 
126
            for name, value in [('LANG', orig_lang), ('LC_ALL', orig_lc_all)]:
 
127
                if value is None:
 
128
                    del os.environ[name]
 
129
                else:
 
130
                    os.environ[name] = value
128
131
 
129
132
    def test_no_external_diff(self):
130
133
        """Check that NoDiff is raised when diff is not available"""
202
205
        # Make sure external_diff doesn't fail in the current LANG
203
206
        lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
204
207
 
205
 
        cmd = ['diff', '-u', 'old', 'new']
 
208
        cmd = ['diff', '-u', '--binary', 'old', 'new']
206
209
        open('old', 'wb').write('\x00foobar\n')
207
210
        open('new', 'wb').write('foo\x00bar\n')
208
211
        pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,