Files
bin
doc
examples
files
lib
python
t
CMDTEST_as_module.py
CMDTEST_exit_nonzero.py
CMDTEST_exit_zero.py
CMDTEST_stdout_equal.py
as_module.py
selftest_utils.py
CMDTEST_example.py
Rakefile
cmdtest.py
src
t
.gitignore
.hgignore
CHANGES.txt
CMDTEST_example.yml
CMakeLists.txt
COPYING.txt
README.html
README.rst
Rakefile
cmdtest.gemspec
file1.txt
file2.txt
replace_strings.pl
run-regression.rb
setup.rb
cmdtest/python/t/selftest_utils.py
2016-01-06 20:55:53 +01:00

31 lines
848 B
Python

import os
from contextlib import contextmanager
TOP = os.getcwd()
class SelftestUtils:
def setup(self):
self.always_ignore_file('tmp-cmdtest-python/')
def create_CMDTEST_foo(self, *lines):
self.create_file("CMDTEST_foo.py", [
"class TC_foo(TestCase):",
" def setup(self):",
" #prepend_path #{BIN.inspect}",
" #prepend_path #{PLATFORM_BIN.inspect}",
" pass",
"",
" def test_foo(self):",
[ " " + line for line in lines],
])
@contextmanager
def cmd_cmdtest(self, *args):
cmdtest = "%s/cmdtest.py" % TOP
command = "%s --quiet CMDTEST_foo.py" % cmdtest
cmdline = ' '.join([command] + list(args))
with self.cmd(cmdline) as c:
yield c