tests/test-toggle.vim @ 7e3c84cb5eb4

Fix TypeError when using Python 3

The error shows up on :Gundo and looks like this:

    Error detected while processing function gundo#GundoShow[1]..<SNR>116_GundoShow[4]..<SNR>116_GundoOpen[31]..<SNR>116_GundoRenderPreview:
    line    2:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/mg/.vim/bundle/Gundo/autoload/gundo.py", line 474, in GundoRenderPreview
        _output_preview_text(_generate_preview_diff(current, node_before, node_after))
      File "/home/mg/.vim/bundle/Gundo/autoload/gundo.py", line 382, in _generate_preview_diff
        before_time, after_time))
      File "/usr/lib/python3.5/difflib.py", line 1177, in unified_diff
        _check_types(a, b, fromfile, tofile, fromfiledate, tofiledate, lineterm)
      File "/usr/lib/python3.5/difflib.py", line 1312, in _check_types
        raise TypeError('all arguments must be str, not: %r' % (arg,))
    TypeError: all arguments must be str, not: 46
author Marius Gedminas <marius@gedmin.as>
date Thu, 24 Nov 2016 14:21:55 +0200
parents a3ab3da8805a
children (none)
UTSuite [Gundo] Testing Toggling

function! s:Setup()"{{{
    exec 'edit test'
    call g:Goto('test')
endfunction"}}}
function! s:Teardown()"{{{
    if bufwinnr(bufnr('__Gundo__')) != -1
        exec bufwinnr(bufnr('__Gundo__')) . 'wincmd w'
        quit
    endif
    if bufwinnr(bufnr('__Gundo_Preview__')) != -1
        exec bufwinnr(bufnr('__Gundo_Preview__')) . 'wincmd w'
        quit
    endif
    if bufnr('__Gundo__') != -1
        exec 'bwipeout ' . bufnr('__Gundo__')
    endif
    if bufnr('__Gundo_Preview__') != -1
        exec 'bwipeout ' . bufnr('__Gundo_Preview__')
    endif
    if bufnr('test') != -1
        exec 'bwipeout ' . bufnr('test')
    endif
    if bufnr('test2') != -1
        exec 'bwipeout ' . bufnr('test2')
    endif
endfunction"}}}

function! s:TestToggleBasic()"{{{
    " Make sure we're starting from scratch.
    Assert bufnr('__Gundo__') == -1
    Assert bufnr('__Gundo_Preview__') == -1
    Assert bufwinnr(bufnr('__Gundo__')) == -1
    Assert bufwinnr(bufnr('__Gundo_Preview__')) == -1

    " Open Gundo
    GundoToggle

    " Buffers and windows should exist.
    Assert bufnr('__Gundo__') != -1
    Assert bufnr('__Gundo_Preview__') != -1
    Assert bufwinnr(bufnr('__Gundo__')) != -1
    Assert bufwinnr(bufnr('__Gundo_Preview__')) != -1

    " We should be in the Gundo pane.
    Assert expand('%') == '__Gundo__'

    " Close Gundo
    GundoToggle

    " Windows should have been closed, but buffers should remain.
    Assert bufnr('__Gundo__') != -1
    Assert bufnr('__Gundo_Preview__') != -1
    Assert bufwinnr(bufnr('__Gundo__')) == -1
    Assert bufwinnr(bufnr('__Gundo_Preview__')) == -1
endfunction"}}}

function! s:TestToggleWhenMoved()"{{{
    " Make sure we're starting from scratch.
    Assert bufnr('__Gundo__') == -1
    Assert bufnr('__Gundo_Preview__') == -1
    Assert bufwinnr(bufnr('__Gundo__')) == -1
    Assert bufwinnr(bufnr('__Gundo_Preview__')) == -1

    " Open Gundo
    GundoToggle

    call g:Goto('test')
    Assert expand('%') == 'test'

    " Close Gundo
    GundoToggle

    " Windows should have been closed, but buffers should remain.
    Assert bufnr('__Gundo__') != -1
    Assert bufnr('__Gundo_Preview__') != -1
    Assert bufwinnr(bufnr('__Gundo__')) == -1
    Assert bufwinnr(bufnr('__Gundo_Preview__')) == -1

    " Open Gundo
    GundoToggle

    call g:Goto('__Gundo_Preview__')
    Assert expand('%') == '__Gundo_Preview__'

    " Close Gundo
    GundoToggle

    " Windows should have been closed, but buffers should remain.
    Assert bufnr('__Gundo__') != -1
    Assert bufnr('__Gundo_Preview__') != -1
    Assert bufwinnr(bufnr('__Gundo__')) == -1
    Assert bufwinnr(bufnr('__Gundo_Preview__')) == -1
endfunction"}}}

function! s:TestToggleReturnToTarget()"{{{
    " Make sure we're starting from scratch.
    Assert bufnr('__Gundo__') == -1
    Assert bufnr('__Gundo_Preview__') == -1
    Assert bufwinnr(bufnr('__Gundo__')) == -1
    Assert bufwinnr(bufnr('__Gundo_Preview__')) == -1

    exec 'new test2'
    call g:Goto('test')

    " Toggle Gundo
    GundoToggle
    GundoToggle

    " We should be returned to test
    Assert expand('%') == 'test'

    " Move to test2
    call g:Goto('test2')

    " Toggle Gundo
    GundoToggle
    GundoToggle

    " We should be returned to test2
    Assert expand('%') == 'test2'
endfunction"}}}