Show More
@@ -80,6 +80,10 b' class BaseRepository(object):' | |||||
80 | def __len__(self): |
|
80 | def __len__(self): | |
81 | return self.count() |
|
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 | @LazyProperty |
|
87 | @LazyProperty | |
84 | def alias(self): |
|
88 | def alias(self): | |
85 | for k, v in settings.BACKENDS.items(): |
|
89 | for k, v in settings.BACKENDS.items(): |
@@ -31,6 +31,19 b' class RepositoryBaseTest(BackendTestMixi' | |||||
31 | self.assertEqual(self.repo.get_user_email(TEST_USER_CONFIG_FILE), |
|
31 | self.assertEqual(self.repo.get_user_email(TEST_USER_CONFIG_FILE), | |
32 | 'foo.bar@example.com') |
|
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 | class RepositoryGetDiffTest(BackendTestMixin): |
|
49 | class RepositoryGetDiffTest(BackendTestMixin): |
General Comments 0
You need to be logged in to leave comments.
Login now