Mercurial > hg
comparison tests/test-linerange.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | 6939b6ac960a |
children | ee3a55c8fd0f |
comparison
equal
deleted
inserted
replaced
43075:57875cf423c9 | 43076:2372284d9457 |
---|---|
15 07 at OLD | 15 07 at OLD |
16 08 at OLD | 16 08 at OLD |
17 09 at OLD | 17 09 at OLD |
18 10 at OLD | 18 10 at OLD |
19 11 at OLD | 19 11 at OLD |
20 '''[1:] # strip initial LF | 20 '''[ |
21 1: | |
22 ] # strip initial LF | |
21 | 23 |
22 text2 = b''' | 24 text2 = b''' |
23 00 at NEW | 25 00 at NEW |
24 01 at NEW | 26 01 at NEW |
25 02 at NEW, 03 at OLD | 27 02 at NEW, 03 at OLD |
30 07 at NEW | 32 07 at NEW |
31 08 at NEW | 33 08 at NEW |
32 09 at NEW | 34 09 at NEW |
33 10 at NEW | 35 10 at NEW |
34 11 at NEW | 36 11 at NEW |
35 '''[1:] # strip initial LF | 37 '''[ |
38 1: | |
39 ] # strip initial LF | |
40 | |
36 | 41 |
37 def filteredblocks(blocks, rangeb): | 42 def filteredblocks(blocks, rangeb): |
38 """return `rangea` extracted from `blocks` coming from | 43 """return `rangea` extracted from `blocks` coming from |
39 `mdiff.blocksinrange` along with the mask of blocks within rangeb. | 44 `mdiff.blocksinrange` along with the mask of blocks within rangeb. |
40 """ | 45 """ |
41 filtered, rangea = mdiff.blocksinrange(blocks, rangeb) | 46 filtered, rangea = mdiff.blocksinrange(blocks, rangeb) |
42 skipped = [b not in filtered for b in blocks] | 47 skipped = [b not in filtered for b in blocks] |
43 return rangea, skipped | 48 return rangea, skipped |
44 | 49 |
50 | |
45 class blocksinrangetests(unittest.TestCase): | 51 class blocksinrangetests(unittest.TestCase): |
46 | |
47 def setUp(self): | 52 def setUp(self): |
48 self.blocks = list(mdiff.allblocks(text1, text2)) | 53 self.blocks = list(mdiff.allblocks(text1, text2)) |
49 assert self.blocks == [ | 54 assert self.blocks == [ |
50 ([0, 3, 0, 2], b'!'), | 55 ([0, 3, 0, 2], b'!'), |
51 ((3, 7, 2, 6), b'='), | 56 ((3, 7, 2, 6), b'='), |
225 except exctype as exc: | 230 except exctype as exc: |
226 self.assertTrue('line range exceeds file size' in str(exc)) | 231 self.assertTrue('line range exceeds file size' in str(exc)) |
227 else: | 232 else: |
228 self.fail('%s not raised' % exctype.__name__) | 233 self.fail('%s not raised' % exctype.__name__) |
229 | 234 |
235 | |
230 if __name__ == '__main__': | 236 if __name__ == '__main__': |
231 import silenttestrunner | 237 import silenttestrunner |
238 | |
232 silenttestrunner.main(__name__) | 239 silenttestrunner.main(__name__) |