def test_none(): """ Block must have nodes """ block = Block([], LineType.act) with pytest.raises(EmptyBlock): block.get_span(13)
def test_context_arrange(first_node_with_tokens): """ Long string spans are counted. """ block = Block([first_node_with_tokens], LineType.act) result = block.get_span(1) assert result == (1, 3)
def test(first_node_with_tokens): """ For a block that contains the whole body of the test, the span is returned as offset values: 1 - first line (line number 6) of test after def 13 - last line of test (line number 18). """ block = Block(first_node_with_tokens.body, LineType._assert) result = block.get_span(5) assert result == (1, 13)
def test_context(first_node_with_tokens): result = Block.build_arrange(first_node_with_tokens.body, 9) assert len(result.nodes) == 2 assert 'data = {' in result.nodes[0].first_token.line assert 'with catch_signal(user_perms_changed) as callback:' in result.nodes[ 1].first_token.line
def test(first_node_with_tokens): """ `pytest.raises()` with statement is the Act node. """ with_mock_node = first_node_with_tokens.body[0] with_pytest_node = with_mock_node.body[0] result = Block.build_act(with_pytest_node) assert result.nodes == (with_pytest_node, ) assert result.line_type == LineType.act
def test(first_node_with_tokens): block = Block(first_node_with_tokens.body, LineType._assert) result = block.get_span(5) assert result == (1, 13)
def test_empty(): result = Block([], LineType.act) assert result.nodes == () assert result.line_type == LineType.act
def test_some(first_node_with_tokens): result = Block(first_node_with_tokens.body, LineType._assert) assert len(result.nodes) == 5
def test_simple(first_node_with_tokens): result = Block.build_arrange(first_node_with_tokens.body, 6) assert len(result.nodes) == 2 assert 'x = 1' in result.nodes[0].first_token.line assert 'y = 1' in result.nodes[1].first_token.line
def test_none(first_node_with_tokens): result = Block.build_arrange(first_node_with_tokens.body, 3) assert isinstance(result, Block) assert result.nodes == () assert result.line_type == LineType.arrange