~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-01-11 15:45:55 UTC
  • mfrom: (5588.1.1 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20110111154555-xmu386vs0qoigyhl
(vila) Document the packaging helper scripts. (Max Bowsher)

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
        self.check_patch(lines)
145
145
 
146
146
    def test_external_diff_binary_lang_c(self):
147
 
        old_env = {}
148
147
        for lang in ('LANG', 'LC_ALL', 'LANGUAGE'):
149
 
            old_env[lang] = osutils.set_or_unset_env(lang, 'C')
150
 
        try:
151
 
            lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
152
 
            # Older versions of diffutils say "Binary files", newer
153
 
            # versions just say "Files".
154
 
            self.assertContainsRe(lines[0],
155
 
                                  '(Binary f|F)iles old and new differ\n')
156
 
            self.assertEquals(lines[1:], ['\n'])
157
 
        finally:
158
 
            for lang, old_val in old_env.iteritems():
159
 
                osutils.set_or_unset_env(lang, old_val)
 
148
            self.overrideEnv(lang, 'C')
 
149
        lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
 
150
        # Older versions of diffutils say "Binary files", newer
 
151
        # versions just say "Files".
 
152
        self.assertContainsRe(lines[0], '(Binary f|F)iles old and new differ\n')
 
153
        self.assertEquals(lines[1:], ['\n'])
160
154
 
161
155
    def test_no_external_diff(self):
162
156
        """Check that NoDiff is raised when diff is not available"""
163
 
        # Use os.environ['PATH'] to make sure no 'diff' command is available
164
 
        orig_path = os.environ['PATH']
165
 
        try:
166
 
            os.environ['PATH'] = ''
167
 
            self.assertRaises(errors.NoDiff, diff.external_diff,
168
 
                              'old', ['boo\n'], 'new', ['goo\n'],
169
 
                              StringIO(), diff_opts=['-u'])
170
 
        finally:
171
 
            os.environ['PATH'] = orig_path
 
157
        # Make sure no 'diff' command is available
 
158
        # XXX: Weird, using None instead of '' breaks the test -- vila 20101216
 
159
        self.overrideEnv('PATH', '')
 
160
        self.assertRaises(errors.NoDiff, diff.external_diff,
 
161
                          'old', ['boo\n'], 'new', ['goo\n'],
 
162
                          StringIO(), diff_opts=['-u'])
172
163
 
173
164
    def test_internal_diff_default(self):
174
165
        # Default internal diff encoding is utf8