144
144
self.check_patch(lines)
146
146
def test_external_diff_binary_lang_c(self):
148
147
for lang in ('LANG', 'LC_ALL', 'LANGUAGE'):
149
old_env[lang] = osutils.set_or_unset_env(lang, 'C')
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'])
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'])
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']
166
os.environ['PATH'] = ''
167
self.assertRaises(errors.NoDiff, diff.external_diff,
168
'old', ['boo\n'], 'new', ['goo\n'],
169
StringIO(), diff_opts=['-u'])
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'])
173
164
def test_internal_diff_default(self):
174
165
# Default internal diff encoding is utf8