/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 breezy/tests/test__dirstate_helpers.py

  • Committer: Breezy landing bot
  • Author(s): Martin
  • Date: 2017-06-10 01:24:21 UTC
  • mfrom: (6673.1.2 lt_by_dirs)
  • Revision ID: breezy.the.bot@gmail.com-20170610012421-s1dcu2apmpvx6b8e
Replace dirstate helpers cmp_by_dirs with lt_by_dirs

Merged from https://code.launchpad.net/~gz/brz/lt_by_dirs/+merge/325435

Show diffs side-by-side

added added

removed removed

Lines of Context:
376
376
        return bisect_dirblock
377
377
 
378
378
 
379
 
class TestCmpByDirs(tests.TestCase):
380
 
    """Test an implementation of cmp_by_dirs()
 
379
class TestLtByDirs(tests.TestCase):
 
380
    """Test an implementation of lt_by_dirs()
381
381
 
382
 
    cmp_by_dirs() compares 2 paths by their directory sections, rather than as
 
382
    lt_by_dirs() compares 2 paths by their directory sections, rather than as
383
383
    plain strings.
384
384
 
385
 
    Child test cases can override ``get_cmp_by_dirs`` to test a specific
 
385
    Child test cases can override ``get_lt_by_dirs`` to test a specific
386
386
    implementation.
387
387
    """
388
388
 
389
 
    def get_cmp_by_dirs(self):
390
 
        """Get a specific implementation of cmp_by_dirs."""
391
 
        from breezy._dirstate_helpers_py import cmp_by_dirs
392
 
        return cmp_by_dirs
 
389
    def get_lt_by_dirs(self):
 
390
        """Get a specific implementation of lt_by_dirs."""
 
391
        from breezy._dirstate_helpers_py import lt_by_dirs
 
392
        return lt_by_dirs
393
393
 
394
394
    def assertCmpByDirs(self, expected, str1, str2):
395
395
        """Compare the two strings, in both directions.
399
399
        :param str1: string to compare
400
400
        :param str2: string to compare
401
401
        """
402
 
        cmp_by_dirs = self.get_cmp_by_dirs()
 
402
        lt_by_dirs = self.get_lt_by_dirs()
403
403
        if expected == 0:
404
404
            self.assertEqual(str1, str2)
405
 
            self.assertEqual(0, cmp_by_dirs(str1, str2))
406
 
            self.assertEqual(0, cmp_by_dirs(str2, str1))
 
405
            self.assertFalse(lt_by_dirs(str1, str2))
 
406
            self.assertFalse(lt_by_dirs(str2, str1))
407
407
        elif expected > 0:
408
 
            self.assertPositive(cmp_by_dirs(str1, str2))
409
 
            self.assertNegative(cmp_by_dirs(str2, str1))
 
408
            self.assertFalse(lt_by_dirs(str1, str2))
 
409
            self.assertTrue(lt_by_dirs(str2, str1))
410
410
        else:
411
 
            self.assertNegative(cmp_by_dirs(str1, str2))
412
 
            self.assertPositive(cmp_by_dirs(str2, str1))
 
411
            self.assertTrue(lt_by_dirs(str1, str2))
 
412
            self.assertFalse(lt_by_dirs(str2, str1))
413
413
 
414
414
    def test_cmp_empty(self):
415
415
        """Compare against the empty string."""
475
475
        self.assertCmpByDirs(-1, 'ab/cd', 'ab-cd')
476
476
 
477
477
    def test_cmp_unicode_not_allowed(self):
478
 
        cmp_by_dirs = self.get_cmp_by_dirs()
479
 
        self.assertRaises(TypeError, cmp_by_dirs, u'Unicode', 'str')
480
 
        self.assertRaises(TypeError, cmp_by_dirs, 'str', u'Unicode')
481
 
        self.assertRaises(TypeError, cmp_by_dirs, u'Unicode', u'Unicode')
 
478
        lt_by_dirs = self.get_lt_by_dirs()
 
479
        self.assertRaises(TypeError, lt_by_dirs, u'Unicode', 'str')
 
480
        self.assertRaises(TypeError, lt_by_dirs, 'str', u'Unicode')
 
481
        self.assertRaises(TypeError, lt_by_dirs, u'Unicode', u'Unicode')
482
482
 
483
483
    def test_cmp_non_ascii(self):
484
484
        self.assertCmpByDirs(-1, '\xc2\xb5', '\xc3\xa5') # u'\xb5', u'\xe5'
488
488
        self.assertCmpByDirs(-1, 'b/a', 'b/\xc2\xb5') # u'b/a', u'b/\xb5'
489
489
 
490
490
 
491
 
class TestCompiledCmpByDirs(TestCmpByDirs):
492
 
    """Test the pyrex implementation of cmp_by_dirs"""
 
491
class TestCompiledLtByDirs(TestLtByDirs):
 
492
    """Test the pyrex implementation of lt_by_dirs"""
493
493
 
494
494
    _test_needs_features = [compiled_dirstate_helpers_feature]
495
495
 
496
 
    def get_cmp_by_dirs(self):
497
 
        from breezy._dirstate_helpers_pyx import cmp_by_dirs
498
 
        return cmp_by_dirs
 
496
    def get_lt_by_dirs(self):
 
497
        from breezy._dirstate_helpers_pyx import lt_by_dirs
 
498
        return lt_by_dirs
499
499
 
500
500
 
501
501
class TestCmpPathByDirblock(tests.TestCase):
778
778
            from breezy._dirstate_helpers_py import _bisect_path_right
779
779
        self.assertIs(_bisect_path_right, dirstate._bisect_path_right)
780
780
 
781
 
    def test_cmp_by_dirs(self):
 
781
    def test_lt_by_dirs(self):
782
782
        if compiled_dirstate_helpers_feature.available():
783
 
            from breezy._dirstate_helpers_pyx import cmp_by_dirs
 
783
            from breezy._dirstate_helpers_pyx import lt_by_dirs
784
784
        else:
785
 
            from breezy._dirstate_helpers_py import cmp_by_dirs
786
 
        self.assertIs(cmp_by_dirs, dirstate.cmp_by_dirs)
 
785
            from breezy._dirstate_helpers_py import lt_by_dirs
 
786
        self.assertIs(lt_by_dirs, dirstate.lt_by_dirs)
787
787
 
788
788
    def test__read_dirblocks(self):
789
789
        if compiled_dirstate_helpers_feature.available():