针对崇高文本的测试和断言框架的基本层

sublime_plugin_tests_base的Python项目详细描述


Sublime插件测试库

Build Status

针对Sublime Text测试和断言框架的基本层

这是sublime-plugin-tests项目的一部分,是Sublime Text的完整测试框架

有关支持的版本和常见问题解答,请参阅sublime-plugin-tests

折旧通知

我们决定不赞成sublime-plugin-tests-base,而赞成randy3k/UnitTesting

它有更大的平台支持,并且为本地开发设计的脆弱性更小。

https://github.com/randy3k/UnitTesting

开始

使用pip install sublime_plugin_tests_base

安装模块

然后,编写测试:

# Load in unittest and test basefromunittestimportTestCasefromsublime_plugin_tests_baseimportBase# Define a TestCaseclassTestLeftDelete(TestCase):deftest_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 testbase=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()
  try:
      # Update the content and selection `ab|c`
      scratch_view.set_content('abc')
      scratch_view.set_sel([(2, 2)])

      # Delete one character to the left `a|c
      scratch_view.run_command('left_delete')

      # Assert the current content
      assert scratch_view.get_content() == 'ac'
  finally:
      # No matter what happens, close the view
      scratch_view.destroy()
""")# Assert the test passed as expectedself.assertEqual(result['success'],True)
$ # Run tests via nosetests
$ nosetests
.
----------------------------------------------------------------------
Ran 1test in 0.076s

OK
travis-ci集成

我们通过travis ci支持崇高文本2和3。

请咨询sublime-plugin-tests#travis-ci-integration了解最新信息。

文件

sublime-plugin-tests-base由两部分组成:测试框架代码(升华文本外部)和测试帮助程序(升华文本内部)。

测试框架代码在正常的开发环境中运行(例如,nosetestslives所在的环境)。测试助手生活在崇高的文本,使您的测试生活更容易。

测试框架
基地(自动杀戮=假)

在Sublime中运行封闭测试的类。它处理捕获和返回错误。

  • 自动终止升华Boolean-如果为真,测试完成时将自动关闭升华文本。
    • 这对于使用同步升华文本(如升华文本2)的无头环境非常有用。
基本目录

运行测试的文件夹。这可用于写入相对导入的文件。

运行测试(action str)

在升华文本的上下文中运行代码。这将捕获发生的任何synchronous错误。为了澄清,如果使用sublime.set_timeout,则无法报告错误。

  • 动作str String-在升华文本上下文中运行的代码。这应该是对视图进行断言,因为数据在result中不可用。

返回:

  • 结果Dictionary-结果容器
    • 成功Boolean-如果没有错误,True。否则,False
    • 发生的错误的元信息String格式的回溯。

测试助手

utils.scratch视图.scratch view

这有助于创建/分解/操作视图。

有关最新信息,请咨询sublime-plugin-tests#utilsscratch_viewscratchview

架构

请查阅sublime-plugin-tests#architecture以获取最新信息。

贡献

代替正式的形式指南,注意保持现有的编码风格。为任何新的或更改的功能添加单元测试。通过./test.sh进行测试。

如果您希望无头运行测试,则此存储库可以与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$ ./test.sh
..
----------------------------------------------------------------------
Ran 2 tests in 2.957s

OK

捐赠

通过gittip支持此项目和others by twolfson

Support via Gittip

无证

截至2013年12月23日,Todd Wolfson已将此存储库及其内容发布到公共域。

它已在UNLICENSE下发布。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java需要64位jdk 1.5 for windows   eclipse运算符+对于参数类型java是未定义的。双,爪哇。双人   未下载文件扩展名为的java文件   java不支持带有POST的媒体类型   从动态创建的多个EditText读取文本时发生java错误   java无法为同一xpath单击多个按钮   如何在Java中动态格式化字符串   java Android Clear Middle活动   多线程Java内存模型volatile和x86   git在Java中通过Jgit忽略文件或文件夹   java“决策无法区分输入的备选方案1、2…”   子类的javajpa继承   java需要弄清楚如何操作mutator来弄清楚一个类,教授说,我对如何操作感到困惑   java如何使用JDBC将数据从文件复制到PostgreSQL?