add tests of 'cmdtest.py' in t/ subdir

This commit is contained in:
Johan Holmberg
2016-01-06 20:55:53 +01:00
parent f0e6f5c281
commit a65f019e51
4 changed files with 190 additions and 0 deletions

@ -0,0 +1,71 @@
from selftest_utils import SelftestUtils
class TC_stdout_equal(SelftestUtils, TestCase):
def test_stdout_equal_CORRECT_EMPTY(self):
self.create_CMDTEST_foo(
'with self.cmd("true") as c:',
' c.stdout_equal([',
' ])',
)
with self.cmd_cmdtest() as c:
c.stdout_equal([
"### cmdline: true",
])
def test_stdout_equal_INCORRECT_EMPTY(self):
self.create_CMDTEST_foo(
'with self.cmd("echo hello") as c:',
' c.stdout_equal([',
' ])',
)
with self.cmd_cmdtest() as c:
c.stdout_equal([
"### cmdline: echo hello",
"--- ERROR: stdout_equal",
"actual:",
" hello",
"expect:",
" <<empty>>",
])
c.exit_nonzero()
def test_stdout_equal_CORRECT_2_LINES(self):
self.create_CMDTEST_foo(
'with self.cmd("echo hello && echo world") as c:',
' c.stdout_equal([',
' "hello",',
' "world",',
' ])',
)
with self.cmd_cmdtest() as c:
c.stdout_equal([
"### cmdline: echo hello && echo world",
])
def test_stdout_equal_INCORRECT_2_LINES(self):
self.create_CMDTEST_foo(
'with self.cmd("echo hello && echo world && echo MORE") as c:',
' c.stdout_equal([',
' "hello",',
' "world",',
' ])',
)
with self.cmd_cmdtest() as c:
c.stdout_equal([
"### cmdline: echo hello && echo world && echo MORE",
"--- ERROR: stdout_equal",
"actual:",
" hello",
" world",
" MORE",
"expect:",
" hello",
" world",
])
c.exit_nonzero()