fname stringlengths 63 176 | rel_fname stringclasses 706
values | line int64 -1 4.5k | name stringlengths 1 81 | kind stringclasses 2
values | category stringclasses 2
values | info stringlengths 0 77.9k ⌀ |
|---|---|---|---|---|---|---|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 611 | AssertionRewriter | def | class | __init__ run is_rewrite_disabled variable assign display helper builtin explanation_param push_format_context pop_format_context generic_visit visit_Assert visit_Name visit_BoolOp visit_UnaryOp visit_BinOp visit_Call visit_Starred visit_Attribute visit_Compare |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 671 | getini | ref | function | self.enable_assertion_pass_hook = config.getini(
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 678 | run | def | function | def run(self, mod: ast.Module) -> None:
"""Find all assert statements in *mod* and rewrite them."""
if not mod.body:
# Nothing to do.
return
# We'll insert some special imports at the top of the module, but after any
# docstrings and __future__ imports, so fi... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 688 | is_rewrite_disabled | ref | function | if doc is not None and self.is_rewrite_disabled(doc):
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 699 | is_rewrite_disabled | ref | function | if self.is_rewrite_disabled(doc):
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 748 | visit | ref | function | new.extend(self.visit(child))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 763 | is_rewrite_disabled | def | function | def is_rewrite_disabled(docstring: str) -> bool:
return "PYTEST_DONT_REWRITE" in docstring
def variable(self) -> str:
"""Get a new variable."""
# Use a character invalid in python identifiers to avoid clashing.
name = "@py_assert" + str(next(self.variable_counter))
self.... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 766 | variable | def | function | def variable(self) -> str:
"""Get a new variable."""
# Use a character invalid in python identifiers to avoid clashing.
name = "@py_assert" + str(next(self.variable_counter))
self.variables.append(name)
return name
def assign(self, expr: ast.expr) -> ast.Name:
""... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 773 | assign | def | function | def assign(self, expr: ast.expr) -> ast.Name:
"""Give *expr* a name."""
name = self.variable()
self.statements.append(ast.Assign([ast.Name(name, ast.Store())], expr))
return ast.Name(name, ast.Load())
def display(self, expr: ast.expr) -> ast.expr:
"""Call saferepr on the... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 775 | variable | ref | function | name = self.variable()
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 779 | display | def | function | def display(self, expr: ast.expr) -> ast.expr:
"""Call saferepr on the expression."""
return self.helper("_saferepr", expr)
def helper(self, name: str, *args: ast.expr) -> ast.expr:
"""Call a helper in this module."""
py_name = ast.Name("@pytest_ar", ast.Load())
attr = a... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 781 | helper | ref | function | return self.helper("_saferepr", expr)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 783 | helper | def | function | def helper(self, name: str, *args: ast.expr) -> ast.expr:
"""Call a helper in this module."""
py_name = ast.Name("@pytest_ar", ast.Load())
attr = ast.Attribute(py_name, name, ast.Load())
return ast.Call(attr, list(args), [])
def builtin(self, name: str) -> ast.Attribute:
... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 789 | builtin | def | function | def builtin(self, name: str) -> ast.Attribute:
"""Return the builtin called *name*."""
builtin_name = ast.Name("@py_builtins", ast.Load())
return ast.Attribute(builtin_name, name, ast.Load())
def explanation_param(self, expr: ast.expr) -> str:
"""Return a new named %-formatting ... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 794 | explanation_param | def | function | def explanation_param(self, expr: ast.expr) -> str:
"""Return a new named %-formatting placeholder for expr.
This creates a %-formatting placeholder for expr in the
current formatting context, e.g. ``%(py0)s``. The placeholder
and expr are placed in the current format context so th... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 806 | push_format_context | def | function | def push_format_context(self) -> None:
"""Create a new formatting context.
The format context is used for when an explanation wants to
have a variable value formatted in the assertion message. In
this case the value required can be added using
.explanation_param(). Finally... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 819 | pop_format_context | def | function | def pop_format_context(self, expl_expr: ast.expr) -> ast.Name:
"""Format the %-formatted string with current format context.
The expl_expr should be an str ast.expr instance constructed from
the %-placeholders created by .explanation_param(). This will
add the required code to form... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 839 | generic_visit | def | function | def generic_visit(self, node: ast.AST) -> Tuple[ast.Name, str]:
"""Handle expressions we don't have custom code for."""
assert isinstance(node, ast.expr)
res = self.assign(node)
return res, self.explanation_param(self.display(res))
def visit_Assert(self, assert_: ast.Assert) -> ... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 842 | assign | ref | function | res = self.assign(node)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 843 | explanation_param | ref | function | return res, self.explanation_param(self.display(res))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 843 | display | ref | function | return res, self.explanation_param(self.display(res))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 845 | visit_Assert | def | function | def visit_Assert(self, assert_: ast.Assert) -> List[ast.stmt]:
"""Return the AST statements to replace the ast.Assert instance.
This rewrites the test of an assertion to provide
intermediate values and replace it with an if statement which
raises an assertion error with a detailed e... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 860 | PytestAssertRewriteWarning | ref | function | PytestAssertRewriteWarning(
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 877 | push_format_context | ref | function | self.push_format_context()
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 879 | visit | ref | function | top_condition, explanation = self.visit(assert_.test)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 884 | pop_format_context | ref | function | msg = self.pop_format_context(ast.Str(explanation))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 888 | helper | ref | function | assertmsg = self.helper("_format_assertmsg", assert_.msg)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 896 | helper | ref | function | fmt = self.helper("_format_explanation", err_msg)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 904 | helper | ref | function | fmt_pass = self.helper("_format_explanation", msg)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 905 | _get_assertion_exprs | ref | function | orig = _get_assertion_exprs(self.source)[assert_.lineno]
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 907 | helper | ref | function | self.helper(
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 916 | helper | ref | function | self.helper("_check_if_assertion_pass_impl"),
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 937 | helper | ref | function | assertmsg = self.helper("_format_assertmsg", assert_.msg)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 943 | pop_format_context | ref | function | msg = self.pop_format_context(template)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 944 | helper | ref | function | fmt = self.helper("_format_explanation", msg)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 958 | traverse_node | ref | function | for node in traverse_node(stmt):
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 962 | visit_Name | def | function | def visit_Name(self, name: ast.Name) -> Tuple[ast.Name, str]:
# Display the repr of the name if it's a local variable or
# _should_repr_global_name() thinks it's acceptable.
locs = ast.Call(self.builtin("locals"), [], [])
inlocs = ast.Compare(ast.Str(name.id), [ast.In()], [locs])
... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 965 | builtin | ref | function | locs = ast.Call(self.builtin("locals"), [], [])
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 967 | helper | ref | function | dorepr = self.helper("_should_repr_global_name", name)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 969 | display | ref | function | expr = ast.IfExp(test, self.display(name), ast.Str(name.id))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 970 | explanation_param | ref | function | return name, self.explanation_param(expr)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 972 | visit_BoolOp | def | function | def visit_BoolOp(self, boolop: ast.BoolOp) -> Tuple[ast.Name, str]:
res_var = self.variable()
expl_list = self.assign(ast.List([], ast.Load()))
app = ast.Attribute(expl_list, "append", ast.Load())
is_or = int(isinstance(boolop.op, ast.Or))
body = save = self.statements
... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 973 | variable | ref | function | res_var = self.variable()
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 974 | assign | ref | function | expl_list = self.assign(ast.List([], ast.Load()))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 980 | push_format_context | ref | function | self.push_format_context()
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 988 | push_format_context | ref | function | self.push_format_context()
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 989 | visit | ref | function | res, expl = self.visit(v)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 991 | pop_format_context | ref | function | expl_format = self.pop_format_context(ast.Str(expl))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,003 | helper | ref | function | expl_template = self.helper("_format_boolop", expl_list, ast.Num(is_or))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,004 | pop_format_context | ref | function | expl = self.pop_format_context(expl_template)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,005 | explanation_param | ref | function | return ast.Name(res_var, ast.Load()), self.explanation_param(expl)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,007 | visit_UnaryOp | def | function | def visit_UnaryOp(self, unary: ast.UnaryOp) -> Tuple[ast.Name, str]:
pattern = UNARY_MAP[unary.op.__class__]
operand_res, operand_expl = self.visit(unary.operand)
res = self.assign(ast.UnaryOp(unary.op, operand_res))
return res, pattern % (operand_expl,)
def visit_BinOp(self, bi... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,009 | visit | ref | function | operand_res, operand_expl = self.visit(unary.operand)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,010 | assign | ref | function | res = self.assign(ast.UnaryOp(unary.op, operand_res))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,013 | visit_BinOp | def | function | def visit_BinOp(self, binop: ast.BinOp) -> Tuple[ast.Name, str]:
symbol = BINOP_MAP[binop.op.__class__]
left_expr, left_expl = self.visit(binop.left)
right_expr, right_expl = self.visit(binop.right)
explanation = f"({left_expl} {symbol} {right_expl})"
res = self.assign(ast.Bi... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,015 | visit | ref | function | left_expr, left_expl = self.visit(binop.left)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,016 | visit | ref | function | right_expr, right_expl = self.visit(binop.right)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,018 | assign | ref | function | res = self.assign(ast.BinOp(left_expr, binop.op, right_expr))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,021 | visit_Call | def | function | def visit_Call(self, call: ast.Call) -> Tuple[ast.Name, str]:
new_func, func_expl = self.visit(call.func)
arg_expls = []
new_args = []
new_kwargs = []
for arg in call.args:
res, expl = self.visit(arg)
arg_expls.append(expl)
new_args.append(... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,022 | visit | ref | function | new_func, func_expl = self.visit(call.func)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,027 | visit | ref | function | res, expl = self.visit(arg)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,031 | visit | ref | function | res, expl = self.visit(keyword.value)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,040 | assign | ref | function | res = self.assign(new_call)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,041 | explanation_param | ref | function | res_expl = self.explanation_param(self.display(res))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,041 | display | ref | function | res_expl = self.explanation_param(self.display(res))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,045 | visit_Starred | def | function | def visit_Starred(self, starred: ast.Starred) -> Tuple[ast.Starred, str]:
# A Starred node can appear in a function call.
res, expl = self.visit(starred.value)
new_starred = ast.Starred(res, starred.ctx)
return new_starred, "*" + expl
def visit_Attribute(self, attr: ast.Attribut... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,047 | visit | ref | function | res, expl = self.visit(starred.value)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,051 | visit_Attribute | def | function | def visit_Attribute(self, attr: ast.Attribute) -> Tuple[ast.Name, str]:
if not isinstance(attr.ctx, ast.Load):
return self.generic_visit(attr)
value, value_expl = self.visit(attr.value)
res = self.assign(ast.Attribute(value, attr.attr, ast.Load()))
res_expl = self.explana... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,053 | generic_visit | ref | function | return self.generic_visit(attr)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,054 | visit | ref | function | value, value_expl = self.visit(attr.value)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,055 | assign | ref | function | res = self.assign(ast.Attribute(value, attr.attr, ast.Load()))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,056 | explanation_param | ref | function | res_expl = self.explanation_param(self.display(res))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,056 | display | ref | function | res_expl = self.explanation_param(self.display(res))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,061 | visit_Compare | def | function | def visit_Compare(self, comp: ast.Compare) -> Tuple[ast.expr, str]:
self.push_format_context()
left_res, left_expl = self.visit(comp.left)
if isinstance(comp.left, (ast.Compare, ast.BoolOp)):
left_expl = f"({left_expl})"
res_variables = [self.variable() for i in range(len... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,062 | push_format_context | ref | function | self.push_format_context()
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,063 | visit | ref | function | left_res, left_expl = self.visit(comp.left)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,066 | variable | ref | function | res_variables = [self.variable() for i in range(len(comp.ops))]
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,074 | visit | ref | function | next_res, next_expl = self.visit(next_operand)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,086 | helper | ref | function | expl_call = self.helper(
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,097 | explanation_param | ref | function | return res, self.explanation_param(self.pop_format_context(expl_call))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,097 | pop_format_context | ref | function | return res, self.explanation_param(self.pop_format_context(expl_call))
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,100 | try_makedirs | def | function | def try_makedirs(cache_dir: Path) -> bool:
"""Attempt to create the given directory and sub-directories exist.
Returns _True if successful or if it already exists.
"""
try:
os.makedirs(cache_dir, exist_ok=_True)
except (FileNotFoundError, NotADirectoryError, FileExistsError):
# One ... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py | src/_pytest/assertion/rewrite.py | 1,122 | get_cache_dir | def | function | def get_cache_dir(file_path: Path) -> Path:
"""Return the cache directory to write .pyc files for the given .py file path."""
if sys.version_info >= (3, 8) and sys.pycache_prefix:
# given:
# prefix = '/tmp/pycs'
# path = '/home/user/proj/test_app.py'
# we want:
# '/... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/truncate.py | src/_pytest/assertion/truncate.py | 17 | truncate_if_required | def | function | def truncate_if_required(
explanation: List[str], item: Item, max_length: Optional[int] = None
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/truncate.py | src/_pytest/assertion/truncate.py | 21 | _should_truncate_item | ref | function | if _should_truncate_item(item):
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/truncate.py | src/_pytest/assertion/truncate.py | 22 | _truncate_explanation | ref | function | return _truncate_explanation(explanation)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/truncate.py | src/_pytest/assertion/truncate.py | 26 | _should_truncate_item | def | function | def _should_truncate_item(item: Item) -> bool:
"""Whether or not this test item is eligible for truncation."""
verbose = item.config.option.verbose
return verbose < 2 and not util.running_on_ci()
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/truncate.py | src/_pytest/assertion/truncate.py | 29 | running_on_ci | ref | function | return verbose < 2 and not util.running_on_ci()
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/truncate.py | src/_pytest/assertion/truncate.py | 32 | _truncate_explanation | def | function | def _truncate_explanation(
input_lines: List[str],
max_lines: Optional[int] = None,
max_chars: Optional[int] = None,
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/truncate.py | src/_pytest/assertion/truncate.py | 56 | _truncate_by_char_count | ref | function | truncated_explanation = _truncate_by_char_count(truncated_explanation, max_chars)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/truncate.py | src/_pytest/assertion/truncate.py | 74 | _truncate_by_char_count | def | function | def _truncate_by_char_count(input_lines: List[str], max_chars: int) -> List[str]:
# Check if truncation required
if len("".join(input_lines)) <= max_chars:
return input_lines
# Find point at which input length exceeds total allowed length
iterated_char_count = 0
for iterated_index, input_li... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 34 | format_explanation | def | function | def format_explanation(explanation: str) -> str:
r"""Format an explanation.
Normally all embedded newlines are escaped, however there are
three exceptions: \n{, \n} and \n~. The first two are intended
cover nested explanations, see function and attribute explanations
for examples (.visit_Call(), v... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 44 | _split_explanation | ref | function | lines = _split_explanation(explanation)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 45 | _format_lines | ref | function | result = _format_lines(lines)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 49 | _split_explanation | def | function | def _split_explanation(explanation: str) -> List[str]:
r"""Return a list of individual lines in the explanation.
This will return a list of lines split on '\n{', '\n}' and '\n~'.
Any other newlines will be escaped and appear in the line as the
literal '\n' characters.
"""
raw_lines = (explanati... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 66 | _format_lines | def | function | def _format_lines(lines: Sequence[str]) -> List[str]:
"""Format the individual lines.
This will replace the '{', '}' and '~' characters of our mini formatting
language with the proper 'where ...', 'and ...' and ' + ...' text, taking
care of indentation along the way.
Return a list of formatted lin... |
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 101 | issequence | def | function | def issequence(x: Any) -> bool:
return isinstance(x, collections.abc.Sequence) and not isinstance(x, str)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 105 | istext | def | function | def istext(x: Any) -> bool:
return isinstance(x, str)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 109 | isdict | def | function | def isdict(x: Any) -> bool:
return isinstance(x, dict)
|
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/util.py | src/_pytest/assertion/util.py | 113 | isset | def | function | def isset(x: Any) -> bool:
return isinstance(x, (set, frozenset))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.