From b8ff144ed56ce0e658c04d25df93f23531de8afc Mon Sep 17 00:00:00 2001 From: David Halter Date: Thu, 22 Aug 2013 17:48:58 +0430 Subject: [PATCH] jedi-vim tests basics --- .travis.yml | 5 +++++ conftest.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ pytest.ini | 3 +++ test/test.vim | 27 +++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 .travis.yml create mode 100644 conftest.py create mode 100644 pytest.ini create mode 100644 test/test.vim diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..142b4a2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: python +install: + - pip install --quiet --use-mirrors pytest +script: + - py.test diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..ec370f6 --- /dev/null +++ b/conftest.py @@ -0,0 +1,55 @@ +import os +import urllib +import zipfile +import subprocess + +CACHE_FOLDER = '.cache' +VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-master') +VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec') +TEST_DIR = 'test' + + +class IntegrationTestFile(object): + def __init__(self, path): + self.path = path + self.skip = None + + def run(self): + output = subprocess.check_output([VSPEC_RUNNER, VSPEC_FOLDER, self.path]) + print output + assert False + + def __repr__(self): + return "<%s: %s>" % (type(self), self.path) + + +def pytest_configure(config): + if not os.path.isdir(CACHE_FOLDER): + os.mkdir(CACHE_FOLDER) + + if not os.path.exists(VSPEC_FOLDER): + url = 'https://github.com/kana/vim-vspec/archive/master.zip' + name, hdrs = urllib.urlretrieve(url) + z = zipfile.ZipFile(name) + for n in z.namelist(): + dest = os.path.join(CACHE_FOLDER, n) + destdir = os.path.dirname(dest) + if not os.path.isdir(destdir): + os.makedirs(destdir) + data = z.read(n) + if not os.path.isdir(dest): + with open(dest, 'w') as f: + f.write(data) + z.close() + os.chmod(VSPEC_RUNNER, 0777) + + +def pytest_generate_tests(metafunc): + """ + :type metafunc: _pytest.python.Metafunc + """ + def collect_tests(): + for f in os.listdir(TEST_DIR): + yield IntegrationTestFile(os.path.join(TEST_DIR, f)) + + metafunc.parametrize('case', list(collect_tests())) diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..16700c3 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +# Ignore all files +norecursedirs = * diff --git a/test/test.vim b/test/test.vim new file mode 100644 index 0000000..112321b --- /dev/null +++ b/test/test.vim @@ -0,0 +1,27 @@ +describe '...' + before + new + put =[ + \ 'foo', + \ 'bar', + \ 'baz', + \ '...', + \ ] + end + + after + close! + end + + it 'blub' + Expect range(1) == [1] + end + + it 'bla' + end + + it 'ble' + end +end + +" vim: et:ts=2:sw=2