Ejemplo n.º 1
0
def test_cant_compile_newline():
    mock = MagicMock(return_value=False)
    with patch('xonsh.ptk.key_bindings.can_compile', mock):
        document = Document('for i in (1, 2, ')
        buffer.set_document(document)
        carriage_return(buffer, cli)
        assert_equal(buffer.document.current_line, '')
Ejemplo n.º 2
0
def test_can_compile_and_executes():
    mock = MagicMock(return_value=True)
    with patch('xonsh.ptk.key_bindings.can_compile', mock):
        document = Document('ls')
        buffer.set_document(document)
        carriage_return(buffer, cli)
        assert bufaccept.mock_calls is not None
Ejemplo n.º 3
0
def test_cant_compile_newline():
    mock = MagicMock(return_value = False)
    with patch('xonsh.ptk.key_bindings.can_compile', mock):
        document = Document('for i in (1, 2, ')
        buffer.set_document(document)
        carriage_return(buffer, cli)
        assert_equal(buffer.document.current_line, '')
Ejemplo n.º 4
0
def test_can_compile_and_executes():
    mock = MagicMock(return_value = True)
    with patch('xonsh.ptk.key_bindings.can_compile', mock):
        document = Document('ls')
        buffer.set_document(document)
        carriage_return(buffer, cli)
        assert bufaccept.mock_calls is not None
Ejemplo n.º 5
0
def test_dedent():
    document = Document(indent_ + 'pass')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, '')

    document = Document(2 * indent_ + 'continue')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, indent_)
Ejemplo n.º 6
0
def test_dedent():
    document = Document(indent_+'pass')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, '')

    document = Document(2*indent_+'continue')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line,indent_)
Ejemplo n.º 7
0
def test_trailing_slash():
    mock = MagicMock(return_value = True)
    with patch('xonsh.ptk.key_bindings.can_compile', mock):
        document = Document('this line will \\')
        buffer.set_document(document)
        carriage_return(buffer, cli)
        if not ON_WINDOWS:
            assert buffer.document.current_line ==  ''
        else:
            assert bufaccept.mock_calls is not None
Ejemplo n.º 8
0
def test_dedent():
    document = Document('\n'+indent_+'pass')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert buffer.document.current_line ==  ''

    document = Document('\n'+2*indent_+'continue')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert buffer.document.current_line == indent_
Ejemplo n.º 9
0
def test_nodedent():
    '''don't dedent if first line of buffer'''
    mock = MagicMock(return_value = True)
    with patch('xonsh.ptk.key_bindings.can_compile', mock):
        document = Document('pass')
        buffer.set_document(document)
        carriage_return(buffer, cli)
        assert bufaccept.mock_calls is not None


    mock = MagicMock(return_value = True)
    with patch('xonsh.ptk.key_bindings.can_compile', mock):
        document = Document(indent_+'pass')
        buffer.set_document(document)
        carriage_return(buffer, cli)
        assert bufaccept.mock_calls is not None
Ejemplo n.º 10
0
def test_trailing_slash():
    document = Document('this line will \\')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, '')
Ejemplo n.º 11
0
def test_continuation_line():
    document = Document('\nsecond line')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, '')
Ejemplo n.º 12
0
def test_colon_indent():
    document = Document('for i in range(5):')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, indent_)
Ejemplo n.º 13
0
def test_trailing_slash():
    document = Document('this line will \\')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, '')
Ejemplo n.º 14
0
def test_continuation_line():
    document = Document('\nsecond line')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, '')
Ejemplo n.º 15
0
def test_colon_indent():
    document = Document('for i in range(5):')
    buffer.set_document(document)
    carriage_return(buffer, cli)
    assert_equal(buffer.document.current_line, indent_)