2020-11-28 21:53:05 +00:00
|
|
|
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
2021-04-11 13:29:34 +00:00
|
|
|
# For details: https://github.com/PyCQA/pylint/blob/master/LICENSE
|
2020-11-28 21:53:05 +00:00
|
|
|
|
|
|
|
import operator
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
from os.path import abspath, dirname
|
2020-12-31 10:36:41 +00:00
|
|
|
from pathlib import Path
|
2020-11-28 21:53:05 +00:00
|
|
|
|
|
|
|
SYS_VERS_STR = "%d%d%d" % sys.version_info[:3]
|
|
|
|
TITLE_UNDERLINES = ["", "=", "-", "."]
|
|
|
|
PREFIX = abspath(dirname(__file__))
|
|
|
|
UPDATE_OPTION = "--update-functional-output"
|
2020-12-31 10:36:41 +00:00
|
|
|
UPDATE_FILE = Path("pylint-functional-test-update")
|
2020-11-28 21:53:05 +00:00
|
|
|
# Common sub-expressions.
|
|
|
|
_MESSAGE = {"msg": r"[a-z][a-z\-]+"}
|
|
|
|
# Matches a #,
|
|
|
|
# - followed by a comparison operator and a Python version (optional),
|
|
|
|
# - followed by a line number with a +/- (optional),
|
|
|
|
# - followed by a list of bracketed message symbols.
|
|
|
|
# Used to extract expected messages from testdata files.
|
|
|
|
_EXPECTED_RE = re.compile(
|
|
|
|
r"\s*#\s*(?:(?P<line>[+-]?[0-9]+):)?"
|
|
|
|
r"(?:(?P<op>[><=]+) *(?P<version>[0-9.]+):)?"
|
|
|
|
r"\s*\[(?P<msgs>%(msg)s(?:,\s*%(msg)s)*)]" % _MESSAGE
|
|
|
|
)
|
|
|
|
|
|
|
|
_OPERATORS = {">": operator.gt, "<": operator.lt, ">=": operator.ge, "<=": operator.le}
|