/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Alexander Belchenko
  • Date: 2007-03-11 19:39:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2335.
  • Revision ID: bialix@ukr.net-20070311193937-nx38jief5kw8pp2f
external diff: no need for special code path for win32 (suggested by John Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from cStringIO import StringIO
19
19
import errno
20
20
import subprocess
21
 
import sys
22
21
from tempfile import TemporaryFile
23
22
 
24
23
from bzrlib.diff import internal_diff, external_diff, show_diff_trees
25
24
from bzrlib.errors import BinaryFile, NoDiff
 
25
import bzrlib.osutils as osutils
26
26
import bzrlib.patiencediff
27
27
from bzrlib.tests import (TestCase, TestCaseWithTransport,
28
28
                          TestCaseInTempDir, TestSkipped)
112
112
        self.check_patch(lines)
113
113
 
114
114
    def test_external_diff_binary_lang_c(self):
115
 
        _old_env = {}
116
 
        langs = ('LANG', 'LC_ALL', 'LANGUAGE')
117
 
        for name in langs:
118
 
            _old_env[name] = os.environ.get(name)
 
115
        old_env = {}
 
116
        for lang in ('LANG', 'LC_ALL', 'LANGUAGE'):
 
117
            old_env[lang] = osutils.set_or_unset_env(lang, 'C')
119
118
        try:
120
 
            os.environ['LANG'] = 'C'
121
 
            os.environ['LC_ALL'] = 'C'
122
 
            if sys.platform == 'win32':
123
 
                # only LANGUAGE has effect on win32
124
 
                os.environ['LANGUAGE'] = 'C'
125
119
            lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
126
120
            # Older versions of diffutils say "Binary files", newer
127
121
            # versions just say "Files".
129
123
                                  '(Binary f|F)iles old and new differ\n')
130
124
            self.assertEquals(lines[1:], ['\n'])
131
125
        finally:
132
 
            for name in langs:
133
 
                value = _old_env[name]
134
 
                if value is None:
135
 
                    if os.environ.get(name) is not None:
136
 
                        del os.environ[name]
137
 
                else:
138
 
                    os.environ[name] = value
 
126
            for lang, old_val in old_env.iteritems():
 
127
                osutils.set_or_unset_env(lang, old_val)
139
128
 
140
129
    def test_no_external_diff(self):
141
130
        """Check that NoDiff is raised when diff is not available"""