~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Martin Pool
  • Date: 2011-06-14 01:26:41 UTC
  • mto: (6034.2.1 integration)
  • mto: This revision was merged to the branch mainline in revision 6043.
  • Revision ID: mbp@canonical.com-20110614012641-dnb69zb57ae5je4w
Move all test features into bzrlib.tests.features

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
from bzrlib.symbol_versioning import deprecated_in
36
36
from bzrlib.tests import features, EncodingAdapter
37
37
from bzrlib.tests.blackbox.test_diff import subst_dates
38
 
 
39
 
 
40
 
class _AttribFeature(tests.Feature):
41
 
 
42
 
    def _probe(self):
43
 
        if (sys.platform not in ('cygwin', 'win32')):
44
 
            return False
45
 
        try:
46
 
            proc = subprocess.Popen(['attrib', '.'], stdout=subprocess.PIPE)
47
 
        except OSError, e:
48
 
            return False
49
 
        return (0 == proc.wait())
50
 
 
51
 
    def feature_name(self):
52
 
        return 'attrib Windows command-line tool'
53
 
 
54
 
AttribFeature = _AttribFeature()
55
 
 
56
 
 
57
 
compiled_patiencediff_feature = tests.ModuleAvailableFeature(
58
 
                                    'bzrlib._patiencediff_c')
 
38
from bzrlib.tests import (
 
39
    features,
 
40
    )
59
41
 
60
42
 
61
43
def udiff_lines(old, new, allow_binary=False):
514
496
        is a binary file in the diff.
515
497
        """
516
498
        # See https://bugs.launchpad.net/bugs/110092.
517
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
499
        self.requireFeature(features.UnicodeFilenameFeature)
518
500
 
519
501
        # This bug isn't triggered with cStringIO.
520
502
        from StringIO import StringIO
539
521
 
540
522
    def test_unicode_filename(self):
541
523
        """Test when the filename are unicode."""
542
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
524
        self.requireFeature(features.UnicodeFilenameFeature)
543
525
 
544
526
        alpha, omega = u'\u03b1', u'\u03c9'
545
527
        autf8, outf8 = alpha.encode('utf8'), omega.encode('utf8')
571
553
        """Test for bug #382699: unicode filenames on Windows should be shown
572
554
        in user encoding.
573
555
        """
574
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
556
        self.requireFeature(features.UnicodeFilenameFeature)
575
557
        # The word 'test' in Russian
576
558
        _russian_test = u'\u0422\u0435\u0441\u0442'
577
559
        directory = _russian_test + u'/'
708
690
             ' \@\@\n-old\n\+new\n\n')
709
691
 
710
692
    def test_diff_kind_change(self):
711
 
        self.requireFeature(tests.SymlinkFeature)
 
693
        self.requireFeature(features.SymlinkFeature)
712
694
        self.build_tree_contents([('old-tree/olddir/',),
713
695
                                  ('old-tree/olddir/oldfile', 'old\n')])
714
696
        self.old_tree.add('olddir')
1172
1154
 
1173
1155
class TestPatienceDiffLib_c(TestPatienceDiffLib):
1174
1156
 
1175
 
    _test_needs_features = [compiled_patiencediff_feature]
 
1157
    _test_needs_features = [features.compiled_patiencediff_feature]
1176
1158
 
1177
1159
    def setUp(self):
1178
1160
        super(TestPatienceDiffLib_c, self).setUp()
1268
1250
 
1269
1251
class TestPatienceDiffLibFiles_c(TestPatienceDiffLibFiles):
1270
1252
 
1271
 
    _test_needs_features = [compiled_patiencediff_feature]
 
1253
    _test_needs_features = [features.compiled_patiencediff_feature]
1272
1254
 
1273
1255
    def setUp(self):
1274
1256
        super(TestPatienceDiffLibFiles_c, self).setUp()
1280
1262
class TestUsingCompiledIfAvailable(tests.TestCase):
1281
1263
 
1282
1264
    def test_PatienceSequenceMatcher(self):
1283
 
        if compiled_patiencediff_feature.available():
 
1265
        if features.compiled_patiencediff_feature.available():
1284
1266
            from bzrlib._patiencediff_c import PatienceSequenceMatcher_c
1285
1267
            self.assertIs(PatienceSequenceMatcher_c,
1286
1268
                          patiencediff.PatienceSequenceMatcher)
1290
1272
                          patiencediff.PatienceSequenceMatcher)
1291
1273
 
1292
1274
    def test_unique_lcs(self):
1293
 
        if compiled_patiencediff_feature.available():
 
1275
        if features.compiled_patiencediff_feature.available():
1294
1276
            from bzrlib._patiencediff_c import unique_lcs_c
1295
1277
            self.assertIs(unique_lcs_c,
1296
1278
                          patiencediff.unique_lcs)
1300
1282
                          patiencediff.unique_lcs)
1301
1283
 
1302
1284
    def test_recurse_matches(self):
1303
 
        if compiled_patiencediff_feature.available():
 
1285
        if features.compiled_patiencediff_feature.available():
1304
1286
            from bzrlib._patiencediff_c import recurse_matches_c
1305
1287
            self.assertIs(recurse_matches_c,
1306
1288
                          patiencediff.recurse_matches)
1356
1338
                         ' on this machine', str(e))
1357
1339
 
1358
1340
    def test_prepare_files_creates_paths_readable_by_windows_tool(self):
1359
 
        self.requireFeature(AttribFeature)
 
1341
        self.requireFeature(features.AttribFeature)
1360
1342
        output = StringIO()
1361
1343
        tree = self.make_branch_and_tree('tree')
1362
1344
        self.build_tree_contents([('tree/file', 'content')])