Running Python unit tests (all tests from file or single test). Also running last test.
Support Linux ans OS X. Windows will be in near future.
- Taras Lyapun (http://lyapun.com/)
You can install plugin through Sublime Package Control, or manually:
Go to your Sublime Text 2 Packages
directory
- OS X:
~/Library/Application\ Support/Sublime\ Text\ 2/Packages
- Linux:
~/.config/sublime-text-2/Packages/
and clone the repository using the command below:
git clone https://github.com/lyapun/sublime-text-2-python-test-runner.git PythonTestRunner
You can set plugin settings and project level, because, probably, you need different settings for different projects.
You should add section "python_test_runner" into "settings" section. And you can specify:
"test_command" - by default is "nosetests".
"test_root" - by default you project root.
"before_test" - before test hook (eg activate env)
"after_test" - after test hook (ag deactivate env)
"test_delimeter" - delimeter which separates test file and test class. E.g. for nosetests is ":", for django default test runner: ".".
- Run single python test:
Command-Shift-R
(orCtrl-Shift-R
for Linux) - Run all python tests from current file:
Command-Shift-T
(orCtrl-Shift-T
for Linux) - Run last python test:
Command-Shift-E
Also you can run tests from context menu, sublime menu (Tools), or command pallete.
For a single test run, test methods must follow the convention where the name starts with 'test.' Running all tests in the current file doesn't have this limitation.
my-project.sublime-project
{
"folders":
[
{
"path": "TestProject"
}
],
"settings":
{
"python_test_runner":
{
"before_test": "source .env/bin/activate",
"after_test": "deactivate",
"test_root": "/Path/To/Project",
"test_delimeter": ":",
"test_command": "make test test="
}
}
}
- Add support for Windows