From 98fa887e5792dcaea32a02fca64372566031b70f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Feb 2015 20:34:38 +0100 Subject: [PATCH 1/6] tests: remove star imports, sort --- test/test_Interpolation.py | 2 +- test/test_SnippetPriorities.py | 2 +- test/vim_test_case.py | 4 ++-- test_all.py | 5 ++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/test_Interpolation.py b/test/test_Interpolation.py index 1453e1d..4834b3e 100644 --- a/test/test_Interpolation.py +++ b/test/test_Interpolation.py @@ -1,6 +1,6 @@ # encoding: utf-8 from test.vim_test_case import VimTestCase as _VimTest -from test.constant import * +from test.constant import EX, JF, ESC from test.util import running_on_windows # ShellCode Interpolation {{{# diff --git a/test/test_SnippetPriorities.py b/test/test_SnippetPriorities.py index 2c30ea5..41f8787 100644 --- a/test/test_SnippetPriorities.py +++ b/test/test_SnippetPriorities.py @@ -1,5 +1,5 @@ from test.vim_test_case import VimTestCase as _VimTest -from test.constant import * +from test.constant import EX, ESC # Snippet Priority {{{# diff --git a/test/vim_test_case.py b/test/vim_test_case.py index 5c5ac30..456754b 100644 --- a/test/vim_test_case.py +++ b/test/vim_test_case.py @@ -10,8 +10,8 @@ import tempfile import textwrap import time import unittest - -from constant import * +from test.constant import (ARR_D, ARR_L, ARR_R, ARR_U, BS, ESC, PYTHON3, + SEQUENCES) def is_process_running(pid): diff --git a/test_all.py b/test_all.py index 3d3fa60..5fe4731 100755 --- a/test_all.py +++ b/test_all.py @@ -43,9 +43,8 @@ import os import platform import subprocess import unittest - -from test.constant import * -from test.vim_interface import * +from test.vim_interface import (create_directory, tempfile, VimInterfaceScreen, + VimInterfaceTmux) def plugin_cache_dir(): From 125e6be7858ebdff99bbaf37d2cbf68a0f0ed3ce Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Feb 2015 20:35:14 +0100 Subject: [PATCH 2/6] tests: minor doc fixes --- test_all.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test_all.py b/test_all.py index 5fe4731..a09a6cb 100755 --- a/test_all.py +++ b/test_all.py @@ -3,8 +3,8 @@ # # To execute this test requires two terminals, one for running Vim and one # for executing the test script. Both terminals should have their current -# working directories set to this directory (the one containing this test.py -# script). +# working directories set to this directory (the one containing this +# test_all.py script). # # In one terminal, launch a GNU ``screen`` session named ``vim``: # $ screen -S vim @@ -16,12 +16,12 @@ # Now, from another terminal, launch the testsuite: # $ ./test_all.py # -# Note: if you want to Vim against the Python 3 bindings, you must launch the +# Note: if you want to use Vim against the Python 3 bindings, you must launch the # test suite using Python 3. For example: # $ python3 ./test_all.py # -# For each test, the test.py script will launch vim with a vimrc, run the test, -# compare the output and exit vim again. The keys are send using screen. +# For each test, the test_all.py script will launch vim with a vimrc, run the +# test, compare the output and exit vim again. The keys are send using screen. # # To limit the tests that are executed, specify a pattern to be used to match # the beginning of the test name. For instance, the following will execute all From 6602da89dd5015720967b5ee15af7c13d69cd59e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Feb 2015 20:35:49 +0100 Subject: [PATCH 3/6] tests: fix duplicate method name (test_SnippetPriorities) --- test/test_SnippetPriorities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_SnippetPriorities.py b/test/test_SnippetPriorities.py index 41f8787..be595cc 100644 --- a/test/test_SnippetPriorities.py +++ b/test/test_SnippetPriorities.py @@ -81,7 +81,7 @@ class SnippetPriorities_FileHasHigherThanAdded(_VimTest): wanted = 'This is a test snippet' -class SnippetPriorities_FileHasHigherThanAdded(_VimTest): +class SnippetPriorities_FileHasHigherThanAdded_neg_prio(_VimTest): files = { 'us/all.snippets': r""" priority -3 snippet test "Test Snippet" b From 936aac8da6a4ca0787b34fe000cff4ada034e4ef Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Feb 2015 20:37:08 +0100 Subject: [PATCH 4/6] tests: add -x / --exitfirst option to fail fast --- test_all.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test_all.py b/test_all.py index a09a6cb..0dbf396 100755 --- a/test_all.py +++ b/test_all.py @@ -104,6 +104,8 @@ if __name__ == '__main__': help='How often should each test be retried before it is ' 'considered failed. Works around flakyness in the terminal ' 'multiplexer and race conditions in writing to the file system.') + p.add_option("-x", "--exitfirst", dest="exitfirst", action="store_true", + help="exit instantly on first error or failed test.") o, args = p.parse_args() if o.interface not in ('screen', 'tmux'): @@ -163,7 +165,8 @@ if __name__ == '__main__': return v = 2 if options.verbose else 1 - res = unittest.TextTestRunner(verbosity=v).run(suite) + res = unittest.TextTestRunner(verbosity=v, + failfast=options.exitfirst).run(suite) main() From 6e787df804eec7593b9436516d096965074d4e90 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Feb 2015 20:37:53 +0100 Subject: [PATCH 5/6] tests: use return code from testrunner --- test_all.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test_all.py b/test_all.py index 0dbf396..49d3155 100755 --- a/test_all.py +++ b/test_all.py @@ -77,6 +77,7 @@ def setup_other_plugins(all_plugins): if __name__ == '__main__': import optparse + import sys def parse_args(): p = optparse.OptionParser('%prog [OPTIONS] ') @@ -165,9 +166,9 @@ if __name__ == '__main__': return v = 2 if options.verbose else 1 - res = unittest.TextTestRunner(verbosity=v, - failfast=options.exitfirst).run(suite) + return unittest.TextTestRunner(verbosity=v, + failfast=options.exitfirst).run(suite) - main() + sys.exit(main()) # vim:fileencoding=utf-8:foldmarker={{{#,#}}}: From 1a3d0ce4b3a97768c7b539bd8c92d6fd98bf3867 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Feb 2015 21:13:17 +0100 Subject: [PATCH 6/6] tests: allow passing in PYTHON, and default to python2 --- test/test_Interpolation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_Interpolation.py b/test/test_Interpolation.py index 4834b3e..30e261a 100644 --- a/test/test_Interpolation.py +++ b/test/test_Interpolation.py @@ -1,4 +1,6 @@ # encoding: utf-8 +import os + from test.vim_test_case import VimTestCase as _VimTest from test.constant import EX, JF, ESC from test.util import running_on_windows @@ -57,9 +59,9 @@ class TabStop_Shell_TestEscapedCharsAndShellVars_Overwrite(_VimTest): class TabStop_Shell_ShebangPython(_VimTest): skip_if = lambda self: running_on_windows() - snippets = ('test', """Hallo ${1:now `#!/usr/bin/env python + snippets = ('test', """Hallo ${1:now `#!/usr/bin/env %s print "Hallo Welt" -`} end""") +`} end""" % (os.environ.get('PYTHON', 'python2'),)) keys = 'test' + EX + JF + 'and more' wanted = 'Hallo now Hallo Welt endand more' # End: ShellCode Interpolation #}}}