-
Notifications
You must be signed in to change notification settings - Fork 259
Using test runner
Ian Clark edited this page Oct 14, 2015
·
5 revisions
The anaconda's test runner is an original contribution by @NorthIsUp.
You can open the Command Palette and write test
until you see the Anaconda: ...
test options or just use right click and select the option that you want from the contextual menu.
- Run Last Tests: It will repeat the last test that you run
- Run Current Test: It will run the test under the cursor
- Run Project Tests: Run the project whole test suite
- Run Current File Tests: Run all the tests defined in the current file
Anaconda test runner support several options to fine tune it's behavior
- test_before_command: if this option is set, anaconda will try to run the given command before run the test suite (if you need to run more than one command, just use a list of commands ["cmd1", "cmd2", ...])
- test_after_command: as before, if this option is set, anaconda will try to run the given command (or commands) after run the test suite
-
test_command: the command to run in order to execute the test suite, this is nosetest by default, for example:
python -m unittest discover
-
test_delimeter: this is the test delimiter to use after your test module names, by default is
:
, for example, if you set this to:
and your module name is "test_server.py" it will trytest_server:ServerTest
- test_virtualenv: if you need to load a virtual environment to execute your test you can configure it here, anaconda will activate it, run your test, and deactivate it
-
test_project_path: if this options is set, anaconda will add whatever text is on it after the command that is going to be used to run the test suite, this is needed for example to run test suites using the
twisted
librarytrial
command. For example"test_project_path": "mamba"
andtrial
as configured command will runtrial mamba
(wheremamba
is a directory)
You can find here some configuration examples in several ways. note: all the configurations are placed in .sublime-project file
Normally, to run a test suite built with Twisted's trial you need to pass a top level directory that contains your tests and is used by it's auto test discovery facility.
{
"build_systems":
[
{
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "python -u \"$file\""
}
],
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"settings": {
"test_command": "trial",
"test_delimeter": ".", // ":" by default
"test_project_path": "myproject"
}
}
{
"settings": {
"test_before_command": "source $HOME/.virtualenvs/myproject/bin/activate",
"test_after_command": "deactivate"
}
}
{
"settings": {
"test_command": "trial",
"test_delimeter": ".",
"test_project_path": "myproject",
"test_virtualenv": "$HOME/.virtualenvs/myproject"
}
}
- Apply
test_[before/after]_command
s to source a virtualenv if required
{
"settings": {
"test_command": "./manage.py test --settings=tests.settings --noinput",
"test_delimeter": "."
}
}
{
"settings": {
"test_command": "python -m unittest discover",
}
}
Must be an absolute path
{
"settings": {
"test_root": "/home/me/project_root/django_root"
}
}