Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Base layer for testing and assertion frameworks against Sublime Text

Project description


Build Status

Base layer for testing and assertion frameworks against Sublime Text

This is part of the sublime-plugin-tests project, a full testing framework for Sublime Text

For supported versions and FAQs, please consult sublime-plugin-tests.

Deprecation notice

We have decided to deprecate sublime-plugin-tests-base in favor of randy3k/UnitTesting.

It has greater platform support and a less brittle design for local development.

Getting Started

Install the module with: pip install sublime_plugin_tests_base

Then, write your tests:

# Load in unittest and test base
from unittest import TestCase
from sublime_plugin_tests_base import Base

# Define a TestCase
class TestLeftDelete(TestCase):
    def test_left_delete_single(self):
        # Each test function *must* return Python with a `run` function
        # `run` will be run inside Sublime Text. Perform your assertions etc there.
        # Run a test
        base = Base()
        result = base.run_test("""
# Use ScratchView utility provided by `sublime_plugin_tests`
from utils.scratch_view import ScratchView

def run():
  # Generate new scratch file
  scratch_view = ScratchView()
      # Update the content and selection `ab|c`
      scratch_view.set_sel([(2, 2)])

      # Delete one character to the left `a|c

      # Assert the current content
      assert scratch_view.get_content() == 'ac'
      # No matter what happens, close the view

        # Assert the test passed as expected
        self.assertEqual(result['success'], True)
$ # Run tests via nosetests
$ nosetests
Ran 1 test in 0.076s


Travis CI integration

We support both Sublime Text 2 and 3 via Travis CI.

Please consult sublime-plugin-tests#travis-ci-integration for the most up-to-date information.


sublime-plugin-tests-base consists of two pieces: test framework code (outside Sublime Text) and test helpers (inside Sublime Text).

The test framework code is run in your normal development environment (e.g. where nosetests lives). The test helpers live inside of Sublime text to make your testing life easier.

Test framework


Class for running enclosed tests inside of Sublime. It handles capturing and returning errors.

  • auto_kill_sublime Boolean - If true, this will close Sublime Text automatically when the test completes.
    • This is useful for headless environments which are using a synchronous Sublime Text (e.g. Sublime Text 2)

Folder where tests are run. This can be used for writing relatively imported files.


Run code within the context of Sublime Text. This will capture any synchronous errors that occur. To clarify, if you use sublime.set_timeout, we cannot report back the error.

  • action_str String - Code to run within the context of Sublime Text. This should be making assertions against views as the data will not be available in the result.


  • result Dictionary - Container for results
    • success Boolean - If there were no errors, True. Otherwise, False.
    • meta_info String - Formatted traceback from the error that occurred.

Test helpers


This assists with creating/tearing down/manipulating views.

Please consult sublime-plugin-tests#utilsscratch_viewscratchview for the most up-to-date information.


Please consult sublime-plugin-tests#architecture for the most up-to-date information.


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Test via ./

If you would like to headlessly run the tests, this repository can be used with Vagrant.

Currently, it is only configured for Sublime Text 3.
$ vagrant up
[default] Importing base box 'precise64'...
$ vagrant ssh st2 # Sublime Text 3
$ # Use `st3` for Sublime Text 2
vagrant@precise64:~$ cd /vagrant
vagrant@precise64:/vagrant$ ./
Ran 2 tests in 2.957s



Support this project and others by twolfson via gittip.

Support via Gittip


As of Dec 23 2013, Todd Wolfson has released this repository and its contents to the public domain.

It has been released under the UNLICENSE.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sublime_plugin_tests_base, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size sublime_plugin_tests_base-1.0.0.tar.gz (9.7 kB) File type Source Python version None Upload date Hashes View hashes
Filename, size (20.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page