mirror of
https://github.com/clearml/wexpect-venv
synced 2025-05-10 15:01:05 +00:00
[FIX][TST] some test was skipped accidentally; [CLN] add no cover for unwanted exceptions.
This commit is contained in:
parent
aabf824c5c
commit
b9e1a06296
@ -17,7 +17,7 @@ PYBIN = '"{}"'.format(sys.executable)
|
|||||||
|
|
||||||
class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_isatty(self):
|
def test_isatty(self):
|
||||||
" Test isatty() is True after spawning process on most platforms. "
|
" Test isatty() is True after spawning process on most platforms. "
|
||||||
child = wexpect.spawn('cat', coverage_console_reader=True)
|
child = wexpect.spawn('cat', coverage_console_reader=True)
|
||||||
@ -27,7 +27,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
return 'skip'
|
return 'skip'
|
||||||
assert child.isatty()
|
assert child.isatty()
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_read(self):
|
def test_read(self):
|
||||||
" Test spawn.read by calls of various size. "
|
" Test spawn.read by calls of various size. "
|
||||||
child = wexpect.spawn('cat', coverage_console_reader=True)
|
child = wexpect.spawn('cat', coverage_console_reader=True)
|
||||||
@ -40,7 +40,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
self.assertEqual(child.read(1), 'c')
|
self.assertEqual(child.read(1), 'c')
|
||||||
self.assertEqual(child.read(2), '\r\n')
|
self.assertEqual(child.read(2), '\r\n')
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_readline_bin_echo(self):
|
def test_readline_bin_echo(self):
|
||||||
" Test spawn('echo'). "
|
" Test spawn('echo'). "
|
||||||
# given,
|
# given,
|
||||||
@ -49,7 +49,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
# exercise,
|
# exercise,
|
||||||
self.assertEqual(child.readline(), 'alpha beta\r\n')
|
self.assertEqual(child.readline(), 'alpha beta\r\n')
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_readline(self):
|
def test_readline(self):
|
||||||
" Test spawn.readline(). "
|
" Test spawn.readline(). "
|
||||||
# when argument 0 is sent, nothing is returned.
|
# when argument 0 is sent, nothing is returned.
|
||||||
@ -77,7 +77,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
assert not child.isalive()
|
assert not child.isalive()
|
||||||
self.assertEqual(child.exitstatus, 0)
|
self.assertEqual(child.exitstatus, 0)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_iter(self):
|
def test_iter(self):
|
||||||
" iterating over lines of spawn.__iter__(). "
|
" iterating over lines of spawn.__iter__(). "
|
||||||
child = wexpect.spawn('echo "abc\r\n123"', coverage_console_reader=True)
|
child = wexpect.spawn('echo "abc\r\n123"', coverage_console_reader=True)
|
||||||
@ -88,7 +88,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
page = page.replace(_CAT_EOF, '')
|
page = page.replace(_CAT_EOF, '')
|
||||||
self.assertEqual(page, 'abc\r\n123\r\n')
|
self.assertEqual(page, 'abc\r\n123\r\n')
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_readlines(self):
|
def test_readlines(self):
|
||||||
" reading all lines of spawn.readlines(). "
|
" reading all lines of spawn.readlines(). "
|
||||||
child = wexpect.spawn('cat', echo=False, coverage_console_reader=True)
|
child = wexpect.spawn('cat', echo=False, coverage_console_reader=True)
|
||||||
@ -105,7 +105,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
assert not child.isalive()
|
assert not child.isalive()
|
||||||
self.assertEqual(child.exitstatus, 0)
|
self.assertEqual(child.exitstatus, 0)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_write(self):
|
def test_write(self):
|
||||||
" write a character and return it in return. "
|
" write a character and return it in return. "
|
||||||
child = wexpect.spawn('cat', coverage_console_reader=True)
|
child = wexpect.spawn('cat', coverage_console_reader=True)
|
||||||
@ -114,7 +114,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
child.readline()
|
child.readline()
|
||||||
self.assertEqual(child.readline(), 'a\r\n')
|
self.assertEqual(child.readline(), 'a\r\n')
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_writelines(self):
|
def test_writelines(self):
|
||||||
" spawn.writelines() "
|
" spawn.writelines() "
|
||||||
child = wexpect.spawn('cat', coverage_console_reader=True)
|
child = wexpect.spawn('cat', coverage_console_reader=True)
|
||||||
@ -126,7 +126,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
line = child.readline()
|
line = child.readline()
|
||||||
self.assertEqual(line, 'abc123xyz\r\n')
|
self.assertEqual(line, 'abc123xyz\r\n')
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_eof(self):
|
def test_eof(self):
|
||||||
" call to expect() after EOF is received raises wexpect.EOF "
|
" call to expect() after EOF is received raises wexpect.EOF "
|
||||||
child = wexpect.spawn('cat', coverage_console_reader=True)
|
child = wexpect.spawn('cat', coverage_console_reader=True)
|
||||||
@ -134,7 +134,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
with self.assertRaises(wexpect.EOF):
|
with self.assertRaises(wexpect.EOF):
|
||||||
child.expect('the unexpected')
|
child.expect('the unexpected')
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_with(self):
|
def test_with(self):
|
||||||
"spawn can be used as a context manager"
|
"spawn can be used as a context manager"
|
||||||
with wexpect.spawn(PYBIN + ' echo_w_prompt.py', coverage_console_reader=True) as p:
|
with wexpect.spawn(PYBIN + ' echo_w_prompt.py', coverage_console_reader=True) as p:
|
||||||
@ -145,14 +145,14 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
|
|
||||||
assert not p.isalive()
|
assert not p.isalive()
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_terminate(self):
|
def test_terminate(self):
|
||||||
" test force terminate always succeeds (SIGKILL). "
|
" test force terminate always succeeds (SIGKILL). "
|
||||||
child = wexpect.spawn('cat', coverage_console_reader=True)
|
child = wexpect.spawn('cat', coverage_console_reader=True)
|
||||||
child.terminate(force=1)
|
child.terminate(force=1)
|
||||||
assert child.terminated
|
assert child.terminated
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_bad_arguments_suggest_fdpsawn(self):
|
def test_bad_arguments_suggest_fdpsawn(self):
|
||||||
" assert custom exception for spawn(int). "
|
" assert custom exception for spawn(int). "
|
||||||
expect_errmsg = "maybe you want to use fdpexpect.fdspawn"
|
expect_errmsg = "maybe you want to use fdpexpect.fdspawn"
|
||||||
@ -160,7 +160,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
".*" + expect_errmsg):
|
".*" + expect_errmsg):
|
||||||
wexpect.spawn(1, coverage_console_reader=True)
|
wexpect.spawn(1, coverage_console_reader=True)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_bad_arguments_second_arg_is_list(self):
|
def test_bad_arguments_second_arg_is_list(self):
|
||||||
" Second argument to spawn, if used, must be only a list."
|
" Second argument to spawn, if used, must be only a list."
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
@ -170,7 +170,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
# not even a tuple,
|
# not even a tuple,
|
||||||
wexpect.spawn('ls', ('-la',), coverage_console_reader=True)
|
wexpect.spawn('ls', ('-la',), coverage_console_reader=True)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_read_after_close_raises_value_error(self):
|
def test_read_after_close_raises_value_error(self):
|
||||||
" Calling read_nonblocking after close raises ValueError. "
|
" Calling read_nonblocking after close raises ValueError. "
|
||||||
# as read_nonblocking underlies all other calls to read,
|
# as read_nonblocking underlies all other calls to read,
|
||||||
@ -195,7 +195,7 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
p.close()
|
p.close()
|
||||||
p.readlines()
|
p.readlines()
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_isalive(self):
|
def test_isalive(self):
|
||||||
" check isalive() before and after EOF. (True, False) "
|
" check isalive() before and after EOF. (True, False) "
|
||||||
child = wexpect.spawn('cat', coverage_console_reader=True)
|
child = wexpect.spawn('cat', coverage_console_reader=True)
|
||||||
@ -205,14 +205,14 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
assert child.isalive() is False
|
assert child.isalive() is False
|
||||||
self.assertFalse(child.isalive())
|
self.assertFalse(child.isalive())
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_bad_type_in_expect(self):
|
def test_bad_type_in_expect(self):
|
||||||
" expect() does not accept dictionary arguments. "
|
" expect() does not accept dictionary arguments. "
|
||||||
child = wexpect.spawn('cat', coverage_console_reader=True)
|
child = wexpect.spawn('cat', coverage_console_reader=True)
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
child.expect({})
|
child.expect({})
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_cwd(self):
|
def test_cwd(self):
|
||||||
" check keyword argument `cwd=' of wexpect.run() "
|
" check keyword argument `cwd=' of wexpect.run() "
|
||||||
try:
|
try:
|
||||||
@ -262,37 +262,37 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
|||||||
# exercise,
|
# exercise,
|
||||||
self.assertEqual(search_string.__str__(), expected_output)
|
self.assertEqual(search_string.__str__(), expected_output)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_searcher_as_string(self):
|
def test_searcher_as_string(self):
|
||||||
" check searcher_string(..).__str__() "
|
" check searcher_string(..).__str__() "
|
||||||
self._test_searcher_as(wexpect.searcher_string)
|
self._test_searcher_as(wexpect.searcher_string)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_searcher_as_string_with_EOF(self):
|
def test_searcher_as_string_with_EOF(self):
|
||||||
" check searcher_string(..).__str__() that includes EOF "
|
" check searcher_string(..).__str__() that includes EOF "
|
||||||
self._test_searcher_as(wexpect.searcher_string, plus=wexpect.EOF)
|
self._test_searcher_as(wexpect.searcher_string, plus=wexpect.EOF)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_searcher_as_string_with_TIMEOUT(self):
|
def test_searcher_as_string_with_TIMEOUT(self):
|
||||||
" check searcher_string(..).__str__() that includes TIMEOUT "
|
" check searcher_string(..).__str__() that includes TIMEOUT "
|
||||||
self._test_searcher_as(wexpect.searcher_string, plus=wexpect.TIMEOUT)
|
self._test_searcher_as(wexpect.searcher_string, plus=wexpect.TIMEOUT)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_searcher_re_as_string(self):
|
def test_searcher_re_as_string(self):
|
||||||
" check searcher_re(..).__str__() "
|
" check searcher_re(..).__str__() "
|
||||||
self._test_searcher_as(wexpect.searcher_re)
|
self._test_searcher_as(wexpect.searcher_re)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_searcher_re_as_string_with_EOF(self):
|
def test_searcher_re_as_string_with_EOF(self):
|
||||||
" check searcher_re(..).__str__() that includes EOF "
|
" check searcher_re(..).__str__() that includes EOF "
|
||||||
self._test_searcher_as(wexpect.searcher_re, plus=wexpect.EOF)
|
self._test_searcher_as(wexpect.searcher_re, plus=wexpect.EOF)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_searcher_re_as_string_with_TIMEOUT(self):
|
def test_searcher_re_as_string_with_TIMEOUT(self):
|
||||||
" check searcher_re(..).__str__() that includes TIMEOUT "
|
" check searcher_re(..).__str__() that includes TIMEOUT "
|
||||||
self._test_searcher_as(wexpect.searcher_re, plus=wexpect.TIMEOUT)
|
self._test_searcher_as(wexpect.searcher_re, plus=wexpect.TIMEOUT)
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy unsupported")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy unsupported")
|
||||||
def test_exception_tb(self):
|
def test_exception_tb(self):
|
||||||
" test get_trace() filters away wexpect/__init__.py calls. "
|
" test get_trace() filters away wexpect/__init__.py calls. "
|
||||||
p = wexpect.spawn('sleep 1', coverage_console_reader=True)
|
p = wexpect.spawn('sleep 1', coverage_console_reader=True)
|
||||||
|
@ -45,7 +45,7 @@ class TestCaseParametricPrinter(PexpectTestCase.PexpectTestCase):
|
|||||||
self._test(['a', 'b', 'c'], [16], [16], [-1, 0, 1])
|
self._test(['a', 'b', 'c'], [16], [16], [-1, 0, 1])
|
||||||
self._test(['a', 'b', 'c'], [16, 32, 64], [16, 32, 64], [-1, 0])
|
self._test(['a', 'b', 'c'], [16, 32, 64], [16, 32, 64], [-1, 0])
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(wexpect, 'legacy_wexpect'), "legacy has bug around refreshing long consoles")
|
@unittest.skipIf(wexpect.spawn_class_name == 'legacy_wexpect', "legacy has bug around refreshing long consoles")
|
||||||
def test_long_console(self):
|
def test_long_console(self):
|
||||||
|
|
||||||
here = os.path.dirname(os.path.abspath(__file__))
|
here = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
@ -22,7 +22,8 @@ if spawn_class_name == 'legacy_wexpect':
|
|||||||
from .legacy_wexpect import searcher_re
|
from .legacy_wexpect import searcher_re
|
||||||
|
|
||||||
__all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'run', 'split_command_line',
|
__all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'run', 'split_command_line',
|
||||||
'__version__', 'ConsoleReader', 'join_args', 'searcher_string', 'searcher_re']
|
'__version__', 'ConsoleReader', 'join_args', 'searcher_string', 'searcher_re',
|
||||||
|
'spawn_class_name']
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
@ -55,4 +56,4 @@ else:
|
|||||||
|
|
||||||
__all__ = ['split_command_line', 'join_args', 'ExceptionPexpect', 'EOF', 'TIMEOUT',
|
__all__ = ['split_command_line', 'join_args', 'ExceptionPexpect', 'EOF', 'TIMEOUT',
|
||||||
'ConsoleReaderSocket', 'ConsoleReaderPipe', 'spawn', 'SpawnSocket', 'SpawnPipe',
|
'ConsoleReaderSocket', 'ConsoleReaderPipe', 'spawn', 'SpawnSocket', 'SpawnPipe',
|
||||||
'run', 'searcher_string', 'searcher_re', '__version__']
|
'run', 'searcher_string', 'searcher_re', '__version__', 'spawn_class_name']
|
||||||
|
@ -43,7 +43,7 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
except SystemExit:
|
except SystemExit: # pragma: no cover
|
||||||
logger.error('Unexpected exception.')
|
logger.error('Unexpected exception.')
|
||||||
logger.info(traceback.format_exc())
|
logger.info(traceback.format_exc())
|
||||||
raise
|
raise
|
||||||
@ -65,7 +65,7 @@ def main():
|
|||||||
|
|
||||||
sys.exit(cons.child_exitstatus)
|
sys.exit(cons.child_exitstatus)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e: # pragma: no cover
|
||||||
logger.error('Unexpected exception.')
|
logger.error('Unexpected exception.')
|
||||||
logger.info(traceback.format_exc())
|
logger.info(traceback.format_exc())
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user