-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests and fix some issues #14
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*~ | ||
.DS_Store | ||
tags | ||
vader.vim/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# vim:set et sw=4 ts=4 tw=79: | ||
|
||
# Test def keyword | ||
#------------------------------------------------------------------------------- | ||
Given python (def foo): | ||
def foo(): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
|
||
Expect python: | ||
def foo(): | ||
"""foo""" | ||
pass | ||
|
||
Given python (def foo with 1 param): | ||
def foo(arg): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
|
||
Expect python: | ||
def foo(arg): | ||
"""foo | ||
|
||
:param arg: | ||
""" | ||
pass | ||
|
||
Given python (def foo with 2 params): | ||
def foo(arg1, arg2): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
|
||
Expect python: | ||
def foo(arg1, arg2): | ||
"""foo | ||
|
||
:param arg1: | ||
:param arg2: | ||
""" | ||
pass | ||
|
||
Given python (def foo with variadic params): | ||
def foo(*arg): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
Expect python: | ||
def foo(*arg): | ||
"""foo | ||
|
||
:param *arg: | ||
""" | ||
pass | ||
|
||
|
||
# Test class keyword | ||
#------------------------------------------------------------------------------- | ||
|
||
|
||
Given python (class Foo): | ||
class Foo(object): | ||
def foo(self): | ||
pass | ||
|
||
def arg1(self, arg1): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
|
||
Expect python: | ||
class Foo(object): | ||
"""Foo""" | ||
def foo(self): | ||
pass | ||
|
||
def arg1(self, arg1): | ||
pass | ||
|
||
|
||
Given python (class Foo): | ||
class Foo(object): | ||
def foo(self): | ||
pass | ||
|
||
def arg1(self, arg1): | ||
pass | ||
|
||
Do (Put cursor to def foo(self)): | ||
j | ||
|
||
Then Execute (Execute Pydocstring on def foo(self)): | ||
Pydocstring | ||
|
||
Expect python: | ||
class Foo(object): | ||
def foo(self): | ||
"""foo""" | ||
pass | ||
|
||
def arg1(self, arg1): | ||
pass | ||
|
||
|
||
Given python (class Foo): | ||
class Foo(object): | ||
def foo(self): | ||
pass | ||
|
||
def arg1(self, arg1): | ||
pass | ||
|
||
Do (Put cursor to def arg1(self, arg1)): | ||
4j | ||
|
||
Then Execute (Execute Pydocstring on def arg1(self, arg1)): | ||
Pydocstring | ||
|
||
Expect python: | ||
class Foo(object): | ||
def foo(self): | ||
pass | ||
|
||
def arg1(self, arg1): | ||
"""arg1 | ||
|
||
:param arg1: | ||
""" | ||
pass | ||
|
||
# Test aync/await keyword | ||
#------------------------------------------------------------------------------- | ||
Given python (async def foo): | ||
async def foo(): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
|
||
Expect python: | ||
async def foo(): | ||
"""foo""" | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# vim:set et sw=4 ts=4 tw=79: | ||
Execute (Setup template dir): | ||
Save g:pydocstring_templates_dir | ||
let g:pydocstring_templates_dir = './test-template/' | ||
|
||
Given python (def foo): | ||
def foo(): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
|
||
|
||
Expect python: | ||
def foo(): | ||
"""foo is """ | ||
pass | ||
|
||
|
||
Given python (def foo with 1 params): | ||
def foo(arg1): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
|
||
Expect python: | ||
def foo(arg1): | ||
"""foo | ||
|
||
arg1: | ||
arg1 is | ||
""" | ||
pass | ||
|
||
|
||
Given python (def foo with 2 params): | ||
def foo(arg1, arg2): | ||
pass | ||
|
||
Execute: | ||
Pydocstring | ||
|
||
Expect python: | ||
def foo(arg1, arg2): | ||
"""foo | ||
|
||
arg1: | ||
arg1 is | ||
arg2: | ||
arg2 is | ||
""" | ||
pass | ||
|
||
Execute (Clear pydocstring_templates_dir): | ||
Restore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
" Minimal vimrc to run tests | ||
" -------------------------- | ||
|
||
set nocompatible | ||
set nu | ||
filetype off | ||
" Clear all rtp | ||
set rtp=$VIMRUNTIME | ||
|
||
|
||
" Add vader.vim to rtp | ||
set rtp+=./vader.vim | ||
|
||
" Add pydocstring folder into rtp | ||
set rtp+=../ | ||
filetype plugin indent on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"watch": "../", | ||
"ignore": [ | ||
".git", | ||
"node_modules/**/node_modules", | ||
"vader.vim" | ||
], | ||
"verbose": true, | ||
"ext": "vader vim", | ||
"execMap": { | ||
"vader": "./run-single-test-file.sh" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Test cases for vim-pydocstring | ||
========================================== | ||
|
||
Prerequisite | ||
------------ | ||
|
||
- [vader.vim](https://github.com/junegunn/vader.vim) | ||
|
||
Before running test, clone vader into this directory with: | ||
|
||
``` | ||
git clone https://github.com/junegunn/vader.vim | ||
``` | ||
|
||
|
||
Run | ||
--- | ||
|
||
``` | ||
./run.sh | ||
``` | ||
|
||
Note that the command need to be executed under `test` folder. | ||
|
||
Use TDD during development (optional) | ||
------------------------------------- | ||
|
||
You need [nodemon](https://github.com/remy/nodemon) to watch for files | ||
change and re-run the test cases in given file. Here I already provide | ||
nodemon configuration (see `nodemon.json`.) | ||
|
||
Run (again, this need to be executed under `test` folder) | ||
|
||
``` | ||
nodemon <test-file>.vader | ||
``` | ||
|
||
Now, if you modify the `vader` or `vim` files in this project, nodemon will | ||
re-run all the test cases (via `run-single-test-file.sh`). | ||
|
||
|
||
### Know issue | ||
|
||
Vim warns `Input is not from a terminal` when we run tests with | ||
`nodemon`. Neovim doesn't. That why in the scripts, we prefer to use | ||
`nvim` if it is found on path. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
############################################################################### | ||
# Execute a single test file # | ||
############################################################################### | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "Please supply an input *.vader file" | ||
exit | ||
fi | ||
|
||
VIM_EXE="vim" | ||
|
||
if hash nvim 2>/dev/null ; then | ||
VIM_EXE="nvim" | ||
fi | ||
|
||
# Open vim with readonly mode just to execute all *.vader tests. | ||
$VIM_EXE -Nu minimal_vimrc -R "+Vader $1" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
############################################################################### | ||
# Execute all test case # | ||
############################################################################### | ||
|
||
VIM_EXE="vim" | ||
|
||
# If nvim is available in PATH, then we prefer to use nvim | ||
# since it works better with nodemon | ||
if hash nvim 2>/dev/null ; then | ||
VIM_EXE="nvim" | ||
fi | ||
|
||
# Open vim with readonly mode just to execute all *.vader tests. | ||
$VIM_EXE -Nu minimal_vimrc -R '+Vader *.vader' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -$VIM_EXE -Nu minimal_vimrc -R '+Vader *.vader'
+$VIM_EXE -Nu minimal_vimrc -R '+Vader! *.vader' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""{{_header_}} | ||
|
||
{{_arg_}}:{{_lf_}}{{_indent_}} {{_arg_}} is | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""{{_header_}} is """ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need
!
run Vim and execVader
command.