django-tmux


Ⅰ. 插件描述

commands for running django unittests from vim and tmux

Ⅱ. 基本信息

创建日期:  2013-04-30
使用用户:  1
Github星:  1
插件作者:  jtrain

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'jtrain/django-tmux'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'jtrain/django-tmux'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'jtrain/django-tmux'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/jtrain/django-tmux

Ⅳ. 文档说明

# Django-Tmux

Run your django tests in a tmux session directly from vim.

Inspired by the work vimux et al have been doing with rails based tests.

Installation

Requires vim with +python or +python3 (check using vim --version)

Install pathogen (skip if you already have pathogen)

Install a vim-tmux manager. I recommend Screen

Clone this repo to your bundle.

cd ~/.vim/bundle
git clone git://github.com/jtrain/django-tmux.git

Features

You can run a single test at a time. Output matches the results of:

python manage.py test appname.TestCase.test_function_name

You can run tests for an entire application at a time. Matches the result of:

python manage.py test appname

How to use

Put your cursor inside your test file on or inside a test function you would like to run.
Then hit the shortcut key (defined below) for run test. It will identify the test function
and the appname will be found.

Or put your cursor outside of a test function (like in setUp or a helper function). The test
suite for the whole app will run instead.

Configuration Options

tmux_djangotest_manage_py (default="python manage.py")
Command you use to run the manage.py file. Use this in combination with
tmux_djangotest_file_prefix to set up your Python/Virtualenv

let g:tmux_djangotest_manage_py="python manage.py"

tmux_djangotest_test_cmd (default="test")
The command you want manage.py to run.
I default to test, but you may use whatever you want

let g:tmux_djangotest_test_cmd="test"

tmux_djangotest_test_file_contains (default="unittest")
The script checks for this word unittest in your test file. If you never
use the word unittest in your test files, put another word here that
is used instead.

let g:tmux_djangotest_test_file_contains="unittest"

tmux_djangotest_file_prefix (default="")
Used alongside tmux_djangotest_manage_py to set up the virtualenv. Note that
an example is source ../bin/activate &&. Note that it must have a && following it.

let g:tmux_djangotest_file_prefix=""

tmux_djangotest_tmux_cmd (default="screen#ScreenShell")
The function you use to send commands to tmux from vim. If you use the suggested screen.vim
project then you are good to go here. Otherwise you will have to look up the specifics of your
tmux handler for what they use to send commands.

let g:tmux_djangotest_tmux_cmd="screen#ScreenShell"

Shortcuts and settings I use for Screen

" settings for screen-tmux
let g:ScreenImpl = "Tmux"
" init with 256 colours
let g:ScreenShellTmuxInitArgs = '-2'
" exit the child tmux when the host vim quits
let g:ScreenShellQuitOnVimExit = 1
" quits a spawned tmux from within vim
map <Leader>q :ScreenQuit<CR>

" shortcut to run test on Ctrl+b
" or use :python if your vim is configured for that.
noremap <C-b> :python3 run_django_test()<CR>

添加新评论