##// END OF EJS Templates
added __eq__ operation on vcs Repository objects...
marcink -
r3692:5f9f4ece beta
parent child Browse files
Show More
@@ -80,6 +80,10 b' class BaseRepository(object):'
80 80 def __len__(self):
81 81 return self.count()
82 82
83 def __eq__(self, other):
84 same_instance = isinstance(other, self.__class__)
85 return same_instance and getattr(other, 'path', None) == self.path
86
83 87 @LazyProperty
84 88 def alias(self):
85 89 for k, v in settings.BACKENDS.items():
@@ -31,6 +31,19 b' class RepositoryBaseTest(BackendTestMixi'
31 31 self.assertEqual(self.repo.get_user_email(TEST_USER_CONFIG_FILE),
32 32 'foo.bar@example.com')
33 33
34 def test_repo_equality(self):
35 self.assertTrue(self.repo == self.repo)
36
37 def test_repo_equality_broken_object(self):
38 import copy
39 _repo = copy.copy(self.repo)
40 delattr(_repo, 'path')
41 self.assertTrue(self.repo != _repo)
42
43 def test_repo_equality_other_object(self):
44 class dummy(object):
45 path = self.repo.path
46 self.assertTrue(self.repo != dummy())
34 47
35 48
36 49 class RepositoryGetDiffTest(BackendTestMixin):
General Comments 0
You need to be logged in to leave comments. Login now