コード例 #1
0
def slice_node(draw):
    lower = draw(hs.one_of(const_node(hs.integers()), hs.none()))
    upper = draw(hs.one_of(const_node(hs.integers()), hs.none()))
    step = draw(hs.one_of(const_node(hs.integers()), hs.none()))
    node = astroid.Slice()
    node.postinit(lower, upper, step)
    return node
コード例 #2
0
def test_inference_invalid_slice(node):
    sub_node = astroid.Subscript()
    slice = astroid.Slice()
    slice.postinit(astroid.Const(0), astroid.Const('a'))
    sub_node.postinit(node, slice)
    module, _ = cs._parse_text(sub_node)
    for subscript_node in module.nodes_of_class(astroid.Subscript):
        assert isinstance(subscript_node.inf_type, TypeFail)