author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Wed, 31 May 2023 18:08:56 +0100 | |
changeset 50674 | c814101560d9 |
parent 48966 | 6000f5b25c9b |
child 51971 | 77e2994bd617 |
permissions | -rw-r--r-- |
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
1 |
import unittest |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
2 |
from mercurial import error, mdiff |
43366
ee3a55c8fd0f
py3: fix exception message check in test-linerange.py's testOutOfRange
Emmanuel Leblond <emmanuel.leblond@gmail.com>
parents:
43076
diff
changeset
|
3 |
from mercurial.utils import stringutil |
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
4 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
5 |
# for readability, line numbers are 0-origin |
37583
6939b6ac960a
py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30717
diff
changeset
|
6 |
text1 = b''' |
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
7 |
00 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
8 |
01 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
9 |
02 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
10 |
02 at NEW, 03 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
11 |
03 at NEW, 04 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
12 |
04 at NEW, 05 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
13 |
05 at NEW, 06 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
14 |
07 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
15 |
08 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
16 |
09 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
17 |
10 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
18 |
11 at OLD |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
19 |
'''[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
20 |
1: |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
21 |
] # strip initial LF |
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
22 |
|
37583
6939b6ac960a
py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30717
diff
changeset
|
23 |
text2 = b''' |
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
24 |
00 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
25 |
01 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
26 |
02 at NEW, 03 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
27 |
03 at NEW, 04 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
28 |
04 at NEW, 05 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
29 |
05 at NEW, 06 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
30 |
06 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
31 |
07 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
32 |
08 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
33 |
09 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
34 |
10 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
35 |
11 at NEW |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
36 |
'''[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
37 |
1: |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
38 |
] # strip initial LF |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
39 |
|
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
40 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
41 |
def filteredblocks(blocks, rangeb): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
42 |
"""return `rangea` extracted from `blocks` coming from |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
43 |
`mdiff.blocksinrange` along with the mask of blocks within rangeb. |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
44 |
""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
45 |
filtered, rangea = mdiff.blocksinrange(blocks, rangeb) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
46 |
skipped = [b not in filtered for b in blocks] |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
47 |
return rangea, skipped |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
48 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
49 |
|
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
50 |
class blocksinrangetests(unittest.TestCase): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
51 |
def setUp(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
52 |
self.blocks = list(mdiff.allblocks(text1, text2)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
53 |
assert self.blocks == [ |
37583
6939b6ac960a
py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30717
diff
changeset
|
54 |
([0, 3, 0, 2], b'!'), |
6939b6ac960a
py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30717
diff
changeset
|
55 |
((3, 7, 2, 6), b'='), |
6939b6ac960a
py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30717
diff
changeset
|
56 |
([7, 12, 6, 12], b'!'), |
6939b6ac960a
py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30717
diff
changeset
|
57 |
((12, 12, 12, 12), b'='), |
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
58 |
], self.blocks |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
59 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
60 |
def testWithinEqual(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
61 |
"""linerange within an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
62 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
63 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
64 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
65 |
# ^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
66 |
linerange2 = (3, 5) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
67 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
68 |
self.assertEqual(linerange1, (4, 6)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
69 |
self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
70 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
71 |
def testWithinEqualStrictly(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
72 |
"""linerange matching exactly an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
73 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
74 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
75 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
76 |
# ^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
77 |
linerange2 = (2, 6) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
78 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
79 |
self.assertEqual(linerange1, (3, 7)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
80 |
self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
81 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
82 |
def testWithinEqualLowerbound(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
83 |
"""linerange at beginning of an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
84 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
85 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
86 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
87 |
# ^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
88 |
linerange2 = (2, 4) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
89 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
90 |
self.assertEqual(linerange1, (3, 5)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
91 |
self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
92 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
93 |
def testWithinEqualLowerboundOneline(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
94 |
"""oneline-linerange at beginning of an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
95 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
96 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
97 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
98 |
# ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
99 |
linerange2 = (2, 3) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
100 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
101 |
self.assertEqual(linerange1, (3, 4)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
102 |
self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
103 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
104 |
def testWithinEqualUpperbound(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
105 |
"""linerange at end of an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
106 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
107 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
108 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
109 |
# ^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
110 |
linerange2 = (3, 6) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
111 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
112 |
self.assertEqual(linerange1, (4, 7)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
113 |
self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
114 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
115 |
def testWithinEqualUpperboundOneLine(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
116 |
"""oneline-linerange at end of an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
117 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
118 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
119 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
120 |
# ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
121 |
linerange2 = (5, 6) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
122 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
123 |
self.assertEqual(linerange1, (6, 7)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
124 |
self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
125 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
126 |
def testWithinFirstBlockNeq(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
127 |
"""linerange within the first "!" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
128 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
129 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
130 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
131 |
# ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
132 |
# | (empty) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
133 |
# ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
134 |
# ^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
135 |
for linerange2 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
136 |
(0, 1), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
137 |
(1, 1), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
138 |
(1, 2), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
139 |
(0, 2), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
140 |
]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
141 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
142 |
self.assertEqual(linerange1, (0, 3)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
143 |
self.assertEqual(skipped, [False, True, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
144 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
145 |
def testWithinLastBlockNeq(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
146 |
"""linerange within the last "!" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
147 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
148 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
149 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
150 |
# ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
151 |
# ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
152 |
# | (empty) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
153 |
# ^^^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
154 |
# ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
155 |
for linerange2 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
156 |
(6, 7), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
157 |
(7, 8), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
158 |
(7, 7), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
159 |
(6, 12), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
160 |
(11, 12), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
161 |
]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
162 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
163 |
self.assertEqual(linerange1, (7, 12)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
164 |
self.assertEqual(skipped, [True, True, False, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
165 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
166 |
def testAccrossTwoBlocks(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
167 |
"""linerange accross two blocks""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
168 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
169 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
170 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
171 |
# ^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
172 |
linerange2 = (1, 5) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
173 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
174 |
self.assertEqual(linerange1, (0, 6)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
175 |
self.assertEqual(skipped, [False, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
176 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
177 |
def testCrossingSeveralBlocks(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
178 |
"""linerange accross three blocks""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
179 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
180 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
181 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
182 |
# ^^^^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
183 |
linerange2 = (1, 8) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
184 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
185 |
self.assertEqual(linerange1, (0, 12)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
186 |
self.assertEqual(skipped, [False, False, False, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
187 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
188 |
def testStartInEqBlock(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
189 |
"""linerange starting in an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
190 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
191 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
192 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
193 |
# ^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
194 |
# ^^^^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
195 |
for linerange2, expectedlinerange1 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
196 |
((5, 9), (6, 12)), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
197 |
((4, 11), (5, 12)), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
198 |
]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
199 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
200 |
self.assertEqual(linerange1, expectedlinerange1) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
201 |
self.assertEqual(skipped, [True, False, False, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
202 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
203 |
def testEndInEqBlock(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
204 |
"""linerange ending in an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
205 |
# IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
206 |
# 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
207 |
# SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
208 |
# ^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
209 |
# ^^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
210 |
for linerange2, expectedlinerange1 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
211 |
((1, 3), (0, 4)), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
212 |
((0, 4), (0, 5)), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
213 |
]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
214 |
linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
215 |
self.assertEqual(linerange1, expectedlinerange1) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
216 |
self.assertEqual(skipped, [False, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
217 |
|
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
218 |
def testOutOfRange(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
219 |
"""linerange exceeding file size""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
220 |
exctype = error.Abort |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
221 |
for linerange2 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
222 |
(0, 34), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
223 |
(15, 12), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
224 |
]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
225 |
# Could be `with self.assertRaises(error.Abort)` but python2.6 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
226 |
# does not have assertRaises context manager. |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
227 |
try: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
228 |
mdiff.blocksinrange(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
229 |
except exctype as exc: |
43366
ee3a55c8fd0f
py3: fix exception message check in test-linerange.py's testOutOfRange
Emmanuel Leblond <emmanuel.leblond@gmail.com>
parents:
43076
diff
changeset
|
230 |
self.assertTrue( |
ee3a55c8fd0f
py3: fix exception message check in test-linerange.py's testOutOfRange
Emmanuel Leblond <emmanuel.leblond@gmail.com>
parents:
43076
diff
changeset
|
231 |
b'line range exceeds file size' |
ee3a55c8fd0f
py3: fix exception message check in test-linerange.py's testOutOfRange
Emmanuel Leblond <emmanuel.leblond@gmail.com>
parents:
43076
diff
changeset
|
232 |
in stringutil.forcebytestr(exc) |
ee3a55c8fd0f
py3: fix exception message check in test-linerange.py's testOutOfRange
Emmanuel Leblond <emmanuel.leblond@gmail.com>
parents:
43076
diff
changeset
|
233 |
) |
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
234 |
else: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
235 |
self.fail('%s not raised' % exctype.__name__) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
236 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
237 |
|
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
238 |
if __name__ == '__main__': |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
239 |
import silenttestrunner |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37583
diff
changeset
|
240 |
|
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
241 |
silenttestrunner.main(__name__) |