tests/test-linerange.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sat, 01 Feb 2020 09:14:36 +0100
branchstable
changeset 44300 5f55b5c35630
parent 43366 ee3a55c8fd0f
child 48875 6000f5b25c9b
permissions -rw-r--r--
test: simplify test-amend.t to avoid race condition Insted on relying on sleep, we could simply have the editor do the file change. This remove the reliance on "sleep" and avoid test failing on heavy load machine. To test this, I reverted the code change in 5558e3437872 and the test started failing again. This is a graft on stable of 141ceec06b55 which should have targeted for stable. Differential Revision: https://phab.mercurial-scm.org/D8103
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30717
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     1
from __future__ import absolute_import
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     2
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     3
import unittest
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     4
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
     5
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
     6
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     7
# 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
     8
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
     9
           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
    10
           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
    11
           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
    12
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
    13
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
    14
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
    15
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
    16
           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
    17
           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
    18
           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
    19
           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
    20
           11 at OLD
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
    21
'''[
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
    22
    1:
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
    23
]  # 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
    24
37583
6939b6ac960a py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30717
diff changeset
    25
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
    26
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
    27
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
    28
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
    29
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
    30
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
    31
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
    32
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
    33
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
    34
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
    35
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
    36
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
    37
11 at NEW
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
    38
'''[
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
    39
    1:
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
    40
]  # strip initial LF
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
    41
30717
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    42
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    43
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
    44
    """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
    45
    `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
    46
    """
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    47
    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
    48
    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
    49
    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
    50
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
    51
30717
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    52
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
    53
    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
    54
        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
    55
        assert self.blocks == [
37583
6939b6ac960a py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30717
diff changeset
    56
            ([0, 3, 0, 2], b'!'),
6939b6ac960a py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30717
diff changeset
    57
            ((3, 7, 2, 6), b'='),
6939b6ac960a py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30717
diff changeset
    58
            ([7, 12, 6, 12], b'!'),
6939b6ac960a py3: add b'' prefixes in tests/test-linerange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30717
diff changeset
    59
            ((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
    60
        ], self.blocks
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    61
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    62
    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
    63
        """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
    64
        # 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
    65
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    66
        # 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
    67
        #        ^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    68
        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
    69
        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
    70
        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
    71
        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
    72
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    73
    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
    74
        """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
    75
        # 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
    76
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    77
        # 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
    78
        #       ^^^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    79
        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
    80
        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
    81
        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
    82
        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
    83
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    84
    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
    85
        """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
    86
        # 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
    87
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    88
        # 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
    89
        #       ^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    90
        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
    91
        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
    92
        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
    93
        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
    94
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    95
    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
    96
        """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
    97
        # 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
    98
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    99
        # 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
   100
        #       ^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   101
        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
   102
        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
   103
        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
   104
        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
   105
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   106
    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
   107
        """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
   108
        # 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
   109
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   110
        # 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
   111
        #        ^^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   112
        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
   113
        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
   114
        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
   115
        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
   116
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   117
    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
   118
        """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
   119
        # 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
   120
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   121
        # 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
   122
        #          ^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   123
        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
   124
        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
   125
        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
   126
        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
   127
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   128
    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
   129
        """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
   130
        # 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
   131
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   132
        # 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
   133
        #     ^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   134
        #      |           (empty)
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   135
        #      ^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   136
        #     ^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   137
        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
   138
            (0, 1),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   139
            (1, 1),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   140
            (1, 2),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   141
            (0, 2),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   142
        ]:
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   143
            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
   144
            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
   145
            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
   146
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   147
    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
   148
        """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
   149
        # 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
   150
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   151
        # 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
   152
        #           ^
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
        #           |      (empty)
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   155
        #           ^^^^^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   156
        #                ^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   157
        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
   158
            (6, 7),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   159
            (7, 8),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   160
            (7, 7),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   161
            (6, 12),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   162
            (11, 12),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   163
        ]:
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   164
            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
   165
            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
   166
            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
   167
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   168
    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
   169
        """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
   170
        # 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
   171
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   172
        # 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
   173
        #      ^^^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   174
        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
   175
        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
   176
        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
   177
        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
   178
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   179
    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
   180
        """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
   181
        # 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
   182
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   183
        # 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
   184
        #      ^^^^^^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   185
        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
   186
        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
   187
        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
   188
        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
   189
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   190
    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
   191
        """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
   192
        # 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
   193
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   194
        # 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
   195
        #          ^^^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   196
        #         ^^^^^^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   197
        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
   198
            ((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
   199
            ((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
   200
        ]:
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   201
            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
   202
            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
   203
            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
   204
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   205
    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
   206
        """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
   207
        # 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
   208
        #     012345678901
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   209
        # 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
   210
        #      ^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   211
        #     ^^^^^
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   212
        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
   213
            ((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
   214
            ((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
   215
        ]:
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   216
            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
   217
            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
   218
            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
   219
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   220
    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
   221
        """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
   222
        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
   223
        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
   224
            (0, 34),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   225
            (15, 12),
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   226
        ]:
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   227
            # 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
   228
            # 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
   229
            try:
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   230
                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
   231
            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
   232
                self.assertTrue(
ee3a55c8fd0f py3: fix exception message check in test-linerange.py's testOutOfRange
Emmanuel Leblond <emmanuel.leblond@gmail.com>
parents: 43076
diff changeset
   233
                    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
   234
                    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
   235
                )
30717
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   236
            else:
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   237
                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
   238
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
   239
30717
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   240
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
   241
    import silenttestrunner
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37583
diff changeset
   242
30717
3eeb8e138e5c mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   243
    silenttestrunner.main(__name__)