MCPcopy Create free account
hub / github.com/numpy/numpy / visit_Call

Method visit_Call

numpy/tests/test_warnings.py:29–55  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

27 self.__filename = filename
28
29 def visit_Call(self, node):
30 p = ParseCall()
31 p.visit(node.func)
32 ast.NodeVisitor.generic_visit(self, node)
33
34 if p.ls[-1] == 'simplefilter' or p.ls[-1] == 'filterwarnings':
35 if node.args[0].value == "ignore":
36 raise AssertionError(
37 "warnings should have an appropriate stacklevel; found in "
38 "{} on line {}".format(self.__filename, node.lineno))
39
40 if p.ls[-1] == 'warn' and (
41 len(p.ls) == 1 or p.ls[-2] == 'warnings'):
42
43 if "testing/tests/test_warnings.py" == self.__filename:
44 # This file
45 return
46
47 # See if stacklevel exists:
48 if len(node.args) == 3:
49 return
50 args = {kw.arg for kw in node.keywords}
51 if "stacklevel" in args:
52 return
53 raise AssertionError(
54 "warnings should have an appropriate stacklevel; found in "
55 "{} on line {}".format(self.__filename, node.lineno))
56
57
58@pytest.mark.slow

Callers

nothing calls this directly

Calls 2

ParseCallClass · 0.85
visitMethod · 0.80

Tested by

no test coverage detected