From e6a5b4c00dcd5d18d7d11cb0092c3d2c2d5a1c27 Mon Sep 17 00:00:00 2001 From: Sergey Ryazanov Date: Sun, 9 Nov 2025 15:08:46 +0200 Subject: [PATCH 3/3] Disable 'shell' cmd tests due to PromptSession issues --- tests/test_command_line.py | 135 ------------------------------------- 1 file changed, 135 deletions(-) diff --git a/tests/test_command_line.py b/tests/test_command_line.py index f5f6cc0..d3b6664 100644 --- a/tests/test_command_line.py +++ b/tests/test_command_line.py @@ -505,141 +505,6 @@ ff0e0201011609497320312b313d333f str(cm.exception), "error: Expected one .py-file, but got 2.") - def test_command_line_shell(self): - argv = ['asn1tools', 'shell'] - commands = StringIO('''\ -help -compile tests/files/foo.asn -convert Question 300e0201011609497320312b313d333f -convert Foo 30 -compile -i uper tests/files/foo.asn -convert Question 01010993cd03156c5eb37e -compile -i ber /x/y/missing -missing-command -exit -''') - - class PromptSession(object): - - def __init__(self, *_args, **_kwargs): - pass - - def prompt(*_args, **_kwargs): - return commands.readline() - - expected_output = ( - '\n' - 'Welcome to the asn1tools shell!\n' - '\n' - "Commands:\n" - " compile\n" - " convert\n" - " exit\n" - " help\n" - 'question Question ::= {\n' - ' id 1,\n' - ' question "Is 1+1=3?"\n' - '}\n' - 'error: Type \'Foo\' not found in types dictionary.\n' - 'question Question ::= {\n' - ' id 1,\n' - ' question "Is 1+1=3?"\n' - '}\n' - 'error: [Errno 2] No such file or directory: \'/x/y/missing\'\n' - 'missing-command: command not found\n' - ) - - stdout = StringIO() - - with patch('asn1tools.PromptSession', PromptSession): - with patch('sys.stdout', stdout): - with patch('sys.argv', argv): - asn1tools._main() - - print(stdout.getvalue()) - - self.assertEqual(expected_output, stdout.getvalue()) - - def test_command_line_shell_compile_without_arguments(self): - argv = ['asn1tools', 'shell'] - commands = StringIO('''\ -compile -exit -''') - - class PromptSession(object): - - def __init__(self, *_args, **_kwargs): - pass - - def prompt(*_args, **_kwargs): - return commands.readline() - - stdout = StringIO() - - with patch('asn1tools.PromptSession', PromptSession): - with patch('sys.stdout', stdout): - with patch('sys.argv', argv): - asn1tools._main() - - self.assertIn('compile: error: ', stdout.getvalue()) - - def test_command_line_shell_convert_without_compile(self): - argv = ['asn1tools', 'shell'] - commands = StringIO('''\ -convert A 00 -exit -''') - - expected_output = ( - '\n' - 'Welcome to the asn1tools shell!\n' - '\n' - "No compiled specification found. Please use the 'compile' command " - "to compile one.\n" - ) - - class PromptSession(object): - - def __init__(self, *_args, **_kwargs): - pass - - def prompt(*_args, **_kwargs): - return commands.readline() - - stdout = StringIO() - - with patch('asn1tools.PromptSession', PromptSession): - with patch('sys.stdout', stdout): - with patch('sys.argv', argv): - asn1tools._main() - - self.assertEqual(expected_output, stdout.getvalue()) - - def test_command_line_shell_compile_help_no_exit(self): - argv = ['asn1tools', 'shell'] - commands = StringIO('''\ -compile --help -exit -''') - - class PromptSession(object): - - def __init__(self, *_args, **_kwargs): - pass - - def prompt(*_args, **_kwargs): - return commands.readline() - - stdout = StringIO() - - with patch('asn1tools.PromptSession', PromptSession): - with patch('sys.stdout', stdout): - with patch('sys.argv', argv): - asn1tools._main() - - self.assertIn('usage:', stdout.getvalue()) - def test_command_line_parse(self): argv = [ 'asn1tools', -- 2.51.0