cmdtest.py: new skip_on_condition() method
This commit is contained in:
parent
efe3cd2261
commit
2b1fbfa0fc
2 changed files with 16 additions and 10 deletions
|
|
@ -95,21 +95,21 @@ class CmdTestBase:
|
||||||
except:
|
except:
|
||||||
msg(f'{fn}: file does not exist or could not be deleted')
|
msg(f'{fn}: file does not exist or could not be deleted')
|
||||||
|
|
||||||
def skip_for_platform(self, name, extra_msg=None):
|
def skip_on_condition(self, condition, message, extra_msg):
|
||||||
if gc.platform == name:
|
if condition:
|
||||||
msg(gray('Skipping test {!r} for {} platform{}'.format(
|
msg(gray('Skipping test {!r} {}{}'.format(
|
||||||
self.test_name,
|
self.test_name,
|
||||||
name,
|
message,
|
||||||
f' ({extra_msg})' if extra_msg else "")))
|
f' ({extra_msg})' if extra_msg else "")))
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def skip_for_mac(self, extra_msg=None):
|
def skip_for_mac(self, extra_msg=None):
|
||||||
return self.skip_for_platform('darwin', extra_msg)
|
return self.skip_on_condition(gc.platform=='darwin', 'for macOS platform', extra_msg)
|
||||||
|
|
||||||
def skip_for_win(self, extra_msg=None):
|
def skip_for_win(self, extra_msg=None):
|
||||||
return self.skip_for_platform('win32', extra_msg)
|
return self.skip_on_condition(gc.platform=='win32', 'for win32 platform', extra_msg)
|
||||||
|
|
||||||
def spawn_chk(self, *args, **kwargs):
|
def spawn_chk(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,12 @@ class CmdTestInput(CmdTestBase):
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def skip_no_readline_insert(self, extra_msg=None):
|
||||||
|
return self.skip_on_condition(
|
||||||
|
gc.platform == 'darwin',
|
||||||
|
' (no readline insert support)',
|
||||||
|
extra_msg)
|
||||||
|
|
||||||
def get_seed_from_stdin(self):
|
def get_seed_from_stdin(self):
|
||||||
self.spawn(msg_only=True)
|
self.spawn(msg_only=True)
|
||||||
from subprocess import run, PIPE
|
from subprocess import run, PIPE
|
||||||
|
|
@ -336,7 +342,7 @@ class CmdTestInput(CmdTestBase):
|
||||||
False)
|
False)
|
||||||
|
|
||||||
def line_input_insert_term1(self):
|
def line_input_insert_term1(self):
|
||||||
if self.skip_for_mac('readline text buffer issues'):
|
if self.skip_no_readline_insert():
|
||||||
return 'skip'
|
return 'skip'
|
||||||
return self._line_input(
|
return self._line_input(
|
||||||
['prompt> ', True, 'foo', True],
|
['prompt> ', True, 'foo', True],
|
||||||
|
|
@ -346,7 +352,7 @@ class CmdTestInput(CmdTestBase):
|
||||||
hold_protect_delay)
|
hold_protect_delay)
|
||||||
|
|
||||||
def line_input_insert_term2(self):
|
def line_input_insert_term2(self):
|
||||||
if self.skip_for_mac('readline text buffer issues'):
|
if self.skip_no_readline_insert():
|
||||||
return 'skip'
|
return 'skip'
|
||||||
return self._line_input(
|
return self._line_input(
|
||||||
['prompt> ', True, 'foo', False],
|
['prompt> ', True, 'foo', False],
|
||||||
|
|
@ -363,7 +369,7 @@ class CmdTestInput(CmdTestBase):
|
||||||
hold_protect_delay)
|
hold_protect_delay)
|
||||||
|
|
||||||
def line_input_edit_term_insert(self):
|
def line_input_edit_term_insert(self):
|
||||||
if self.skip_for_mac('readline text buffer issues'):
|
if self.skip_no_readline_insert():
|
||||||
return 'skip'
|
return 'skip'
|
||||||
return self._line_input(
|
return self._line_input(
|
||||||
['prompt> ', True, 'φυφυ', True],
|
['prompt> ', True, 'φυφυ', True],
|
||||||
|
|
@ -373,7 +379,7 @@ class CmdTestInput(CmdTestBase):
|
||||||
hold_protect_delay)
|
hold_protect_delay)
|
||||||
|
|
||||||
def line_input_erase_term(self):
|
def line_input_erase_term(self):
|
||||||
if self.skip_for_mac('readline text buffer issues'):
|
if self.skip_no_readline_insert():
|
||||||
return 'skip'
|
return 'skip'
|
||||||
return self._line_input(
|
return self._line_input(
|
||||||
['prompt> ', True, 'foobarbaz', True],
|
['prompt> ', True, 'foobarbaz', True],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue