2017-01-03 20:15:58 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import unittest
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import error, mdiff
|
2020-01-31 11:16:29 +03:00
|
|
|
from hghave import require
|
2020-01-31 05:40:49 +03:00
|
|
|
|
|
|
|
|
2020-01-31 11:16:29 +03:00
|
|
|
require(["py2"])
|
2017-01-03 20:15:58 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-01-03 20:15:58 +03:00
|
|
|
# for readability, line numbers are 0-origin
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
text1 = """
|
2017-01-03 20:15:58 +03:00
|
|
|
00 at OLD
|
|
|
|
01 at OLD
|
|
|
|
02 at OLD
|
|
|
|
02 at NEW, 03 at OLD
|
|
|
|
03 at NEW, 04 at OLD
|
|
|
|
04 at NEW, 05 at OLD
|
|
|
|
05 at NEW, 06 at OLD
|
|
|
|
07 at OLD
|
|
|
|
08 at OLD
|
|
|
|
09 at OLD
|
|
|
|
10 at OLD
|
|
|
|
11 at OLD
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""[
|
|
|
|
1:
|
|
|
|
] # strip initial LF
|
2017-01-03 20:15:58 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
text2 = """
|
2017-01-03 20:15:58 +03:00
|
|
|
00 at NEW
|
|
|
|
01 at NEW
|
|
|
|
02 at NEW, 03 at OLD
|
|
|
|
03 at NEW, 04 at OLD
|
|
|
|
04 at NEW, 05 at OLD
|
|
|
|
05 at NEW, 06 at OLD
|
|
|
|
06 at NEW
|
|
|
|
07 at NEW
|
|
|
|
08 at NEW
|
|
|
|
09 at NEW
|
|
|
|
10 at NEW
|
|
|
|
11 at NEW
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""[
|
|
|
|
1:
|
|
|
|
] # strip initial LF
|
|
|
|
|
2017-01-03 20:15:58 +03:00
|
|
|
|
|
|
|
def filteredblocks(blocks, rangeb):
|
|
|
|
"""return `rangea` extracted from `blocks` coming from
|
|
|
|
`mdiff.blocksinrange` along with the mask of blocks within rangeb.
|
|
|
|
"""
|
|
|
|
filtered, rangea = mdiff.blocksinrange(blocks, rangeb)
|
|
|
|
skipped = [b not in filtered for b in blocks]
|
|
|
|
return rangea, skipped
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-01-03 20:15:58 +03:00
|
|
|
class blocksinrangetests(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.blocks = list(mdiff.allblocks(text1, text2))
|
|
|
|
assert self.blocks == [
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
([0, 3, 0, 2], "!"),
|
|
|
|
((3, 7, 2, 6), "="),
|
|
|
|
([7, 12, 6, 12], "!"),
|
|
|
|
((12, 12, 12, 12), "="),
|
2017-01-03 20:15:58 +03:00
|
|
|
], self.blocks
|
|
|
|
|
|
|
|
def testWithinEqual(self):
|
|
|
|
"""linerange within an "=" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^^
|
|
|
|
linerange2 = (3, 5)
|
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (4, 6))
|
|
|
|
self.assertEqual(skipped, [True, False, True, True])
|
|
|
|
|
|
|
|
def testWithinEqualStrictly(self):
|
|
|
|
"""linerange matching exactly an "=" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^^^^
|
|
|
|
linerange2 = (2, 6)
|
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (3, 7))
|
|
|
|
self.assertEqual(skipped, [True, False, True, True])
|
|
|
|
|
|
|
|
def testWithinEqualLowerbound(self):
|
|
|
|
"""linerange at beginning of an "=" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^^
|
|
|
|
linerange2 = (2, 4)
|
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (3, 5))
|
|
|
|
self.assertEqual(skipped, [True, False, True, True])
|
|
|
|
|
|
|
|
def testWithinEqualLowerboundOneline(self):
|
|
|
|
"""oneline-linerange at beginning of an "=" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^
|
|
|
|
linerange2 = (2, 3)
|
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (3, 4))
|
|
|
|
self.assertEqual(skipped, [True, False, True, True])
|
|
|
|
|
|
|
|
def testWithinEqualUpperbound(self):
|
|
|
|
"""linerange at end of an "=" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^^^
|
|
|
|
linerange2 = (3, 6)
|
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (4, 7))
|
|
|
|
self.assertEqual(skipped, [True, False, True, True])
|
|
|
|
|
|
|
|
def testWithinEqualUpperboundOneLine(self):
|
|
|
|
"""oneline-linerange at end of an "=" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^
|
|
|
|
linerange2 = (5, 6)
|
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (6, 7))
|
|
|
|
self.assertEqual(skipped, [True, False, True, True])
|
|
|
|
|
|
|
|
def testWithinFirstBlockNeq(self):
|
|
|
|
"""linerange within the first "!" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^
|
|
|
|
# | (empty)
|
|
|
|
# ^
|
|
|
|
# ^^
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for linerange2 in [(0, 1), (1, 1), (1, 2), (0, 2)]:
|
2017-01-03 20:15:58 +03:00
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (0, 3))
|
|
|
|
self.assertEqual(skipped, [False, True, True, True])
|
|
|
|
|
|
|
|
def testWithinLastBlockNeq(self):
|
|
|
|
"""linerange within the last "!" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^
|
|
|
|
# ^
|
|
|
|
# | (empty)
|
|
|
|
# ^^^^^^
|
|
|
|
# ^
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for linerange2 in [(6, 7), (7, 8), (7, 7), (6, 12), (11, 12)]:
|
2017-01-03 20:15:58 +03:00
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (7, 12))
|
|
|
|
self.assertEqual(skipped, [True, True, False, True])
|
|
|
|
|
|
|
|
def testAccrossTwoBlocks(self):
|
|
|
|
"""linerange accross two blocks"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^^^^
|
|
|
|
linerange2 = (1, 5)
|
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (0, 6))
|
|
|
|
self.assertEqual(skipped, [False, False, True, True])
|
|
|
|
|
|
|
|
def testCrossingSeveralBlocks(self):
|
|
|
|
"""linerange accross three blocks"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^^^^^^^
|
|
|
|
linerange2 = (1, 8)
|
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, (0, 12))
|
|
|
|
self.assertEqual(skipped, [False, False, False, True])
|
|
|
|
|
|
|
|
def testStartInEqBlock(self):
|
|
|
|
"""linerange starting in an "=" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^^^^
|
|
|
|
# ^^^^^^^
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for linerange2, expectedlinerange1 in [((5, 9), (6, 12)), ((4, 11), (5, 12))]:
|
2017-01-03 20:15:58 +03:00
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, expectedlinerange1)
|
|
|
|
self.assertEqual(skipped, [True, False, False, True])
|
|
|
|
|
|
|
|
def testEndInEqBlock(self):
|
|
|
|
"""linerange ending in an "=" block"""
|
|
|
|
# IDX 0 1
|
|
|
|
# 012345678901
|
|
|
|
# SRC NNOOOONNNNNN (New/Old)
|
|
|
|
# ^^
|
|
|
|
# ^^^^^
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for linerange2, expectedlinerange1 in [((1, 3), (0, 4)), ((0, 4), (0, 5))]:
|
2017-01-03 20:15:58 +03:00
|
|
|
linerange1, skipped = filteredblocks(self.blocks, linerange2)
|
|
|
|
self.assertEqual(linerange1, expectedlinerange1)
|
|
|
|
self.assertEqual(skipped, [False, False, True, True])
|
|
|
|
|
|
|
|
def testOutOfRange(self):
|
|
|
|
"""linerange exceeding file size"""
|
|
|
|
exctype = error.Abort
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for linerange2 in [(0, 34), (15, 12)]:
|
2017-01-03 20:15:58 +03:00
|
|
|
# Could be `with self.assertRaises(error.Abort)` but python2.6
|
|
|
|
# does not have assertRaises context manager.
|
|
|
|
try:
|
|
|
|
mdiff.blocksinrange(self.blocks, linerange2)
|
|
|
|
except exctype as exc:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self.assertTrue("line range exceeds file size" in str(exc))
|
2017-01-03 20:15:58 +03:00
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self.fail("%s not raised" % exctype.__name__)
|
|
|
|
|
2017-01-03 20:15:58 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if __name__ == "__main__":
|
2017-01-03 20:15:58 +03:00
|
|
|
import silenttestrunner
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-01-03 20:15:58 +03:00
|
|
|
silenttestrunner.main(__name__)
|