Mercurial > python-hglib
diff tests/test-grep.py @ 211:1a318162f06f
grep: update tests to cope with behavior change in hg 5.2
I wonder if we should make hglib's grep behave consistently across all
hg versions somehow, but I'm not going to attempt that for now.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Wed, 11 Dec 2019 10:20:58 -0500 |
parents | c1b966866ed7 |
children | 388820908580 |
line wrap: on
line diff
--- a/tests/test-grep.py Wed Dec 11 09:39:53 2019 -0500 +++ b/tests/test-grep.py Wed Dec 11 10:20:58 2019 -0500 @@ -10,13 +10,22 @@ # no match self.assertEquals(list(self.client.grep(b('c'))), []) - self.assertEquals(list(self.client.grep(b('a'))), - [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))]) - self.assertEquals(list(self.client.grep(b('a'), b('a'))), - [(b('a'), b('0'), b('a'))]) + if self.client.version >= (5, 2): + self.assertEquals(list(self.client.grep(b('a'))), + [(b('a'), b('a'), b('b'))]) + self.assertEquals(list(self.client.grep(b('a'), b('a'))), + [(b('a'), b('a'), b(''))]) - self.assertEquals(list(self.client.grep(b('b'))), - [(b('b'), b('0'), b('ab'))]) + self.assertEquals(list(self.client.grep(b('b'))), + [(b('b'), b('ab'), b(''))]) + else: + self.assertEquals(list(self.client.grep(b('a'))), + [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))]) + self.assertEquals(list(self.client.grep(b('a'), b('a'))), + [(b('a'), b('0'), b('a'))]) + + self.assertEquals(list(self.client.grep(b('b'))), + [(b('b'), b('0'), b('ab'))]) def test_options(self): self.append('a', 'a\n') @@ -27,16 +36,26 @@ (b('b'), b('0'), b('+'), b('ab'))], list(self.client.grep(b('a'), all=True))) - self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))], - list(self.client.grep(b('a'), fileswithmatches=True))) + if self.client.version >= (5, 2): + self.assertEquals([(b('a'), b('b'))], + list(self.client.grep(b('a'), fileswithmatches=True))) + + self.assertEquals([(b('a'), b('1'), b('a'), b('b'))], + list(self.client.grep(b('a'), line=True))) - self.assertEquals([(b('a'), b('0'), b('1'), b('a')), - (b('b'), b('0'), b('1'), b('ab'))], - list(self.client.grep(b('a'), line=True))) + self.assertEquals([(b('a'), b('test'), b('a'), b('b'))], + list(self.client.grep(b('a'), user=True))) + else: + self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))], + list(self.client.grep(b('a'), fileswithmatches=True))) - self.assertEquals([(b('a'), b('0'), b('test'), b('a')), - (b('b'), b('0'), b('test'), b('ab'))], - list(self.client.grep(b('a'), user=True))) + self.assertEquals([(b('a'), b('0'), b('1'), b('a')), + (b('b'), b('0'), b('1'), b('ab'))], + list(self.client.grep(b('a'), line=True))) + + self.assertEquals([(b('a'), b('0'), b('test'), b('a')), + (b('b'), b('0'), b('test'), b('ab'))], + list(self.client.grep(b('a'), user=True))) self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')), (b('b'), b('0'), b('1'), b('+'), b('test'))],