/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: Jelmer Vernooij
  • Date: 2017-06-10 01:43:31 UTC
  • mfrom: (6676 work)
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170610014331-1xalwmij33imwidq
Merge trunk.

Show diffs side-by-side

added added

removed removed

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