diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-14 00:49:36 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-14 00:49:36 +0300 |
commit | 82cfd1b7cab2d843cdf5467d9737f72597a493bd (patch) | |
tree | 1dfdcfe81a1a6b193ceacc2a828c521b657a339b /contrib/python/pytest/py3/_pytest/mark/expression.py | |
parent | 3df7211d3e3691f8e33b0a1fb1764fe810d59302 (diff) | |
download | ydb-82cfd1b7cab2d843cdf5467d9737f72597a493bd.tar.gz |
intermediate changes
ref:68b1302de4b5da30b6bdf02193f7a2604d8b5cf8
Diffstat (limited to 'contrib/python/pytest/py3/_pytest/mark/expression.py')
-rw-r--r-- | contrib/python/pytest/py3/_pytest/mark/expression.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/contrib/python/pytest/py3/_pytest/mark/expression.py b/contrib/python/pytest/py3/_pytest/mark/expression.py index dc3991b10c..92220d7723 100644 --- a/contrib/python/pytest/py3/_pytest/mark/expression.py +++ b/contrib/python/pytest/py3/_pytest/mark/expression.py @@ -6,7 +6,7 @@ expression: expr? EOF expr: and_expr ('or' and_expr)* and_expr: not_expr ('and' not_expr)* not_expr: 'not' not_expr | '(' expr ')' | ident -ident: (\w|:|\+|-|\.|\[|\])+ +ident: (\w|:|\+|-|\.|\[|\]|\\|/)+ The semantics are: @@ -47,11 +47,11 @@ class TokenType(enum.Enum): EOF = "end of input" -@attr.s(frozen=True, slots=True) +@attr.s(frozen=True, slots=True, auto_attribs=True) class Token: - type = attr.ib(type=TokenType) - value = attr.ib(type=str) - pos = attr.ib(type=int) + type: TokenType + value: str + pos: int class ParseError(Exception): @@ -88,7 +88,7 @@ class Scanner: yield Token(TokenType.RPAREN, ")", pos) pos += 1 else: - match = re.match(r"(:?\w|:|\+|-|\.|\[|\])+", input[pos:]) + match = re.match(r"(:?\w|:|\+|-|\.|\[|\]|\\|/)+", input[pos:]) if match: value = match.group(0) if value == "or": @@ -102,7 +102,8 @@ class Scanner: pos += len(value) else: raise ParseError( - pos + 1, 'unexpected character "{}"'.format(input[pos]), + pos + 1, + f'unexpected character "{input[pos]}"', ) yield Token(TokenType.EOF, "", pos) @@ -120,7 +121,8 @@ class Scanner: raise ParseError( self.current.pos + 1, "expected {}; got {}".format( - " OR ".join(type.value for type in expected), self.current.type.value, + " OR ".join(type.value for type in expected), + self.current.type.value, ), ) @@ -188,7 +190,7 @@ class MatcherAdapter(Mapping[str, bool]): class Expression: """A compiled match expression as used by -k and -m. - The expression can be evaulated against different matchers. + The expression can be evaluated against different matchers. """ __slots__ = ("code",) @@ -204,7 +206,9 @@ class Expression: """ astexpr = expression(Scanner(input)) code: types.CodeType = compile( - astexpr, filename="<pytest match expression>", mode="eval", + astexpr, + filename="<pytest match expression>", + mode="eval", ) return Expression(code) |