From f7441431697e4ba94202a1484721ae8acf3a4ab7 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Tue, 18 Feb 2020 21:05:10 -0500 Subject: Moved custom cmd2 exceptions to a separate file and removed them from public API --- tests/test_cmd2.py | 4 ++-- tests/test_parsing.py | 6 +++--- tests/test_plugin.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index dc9a3fa1..2db52d39 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -20,7 +20,7 @@ except ImportError: from unittest import mock import cmd2 -from cmd2 import ansi, clipboard, constants, plugin, utils, COMMAND_NAME +from cmd2 import ansi, clipboard, constants, exceptions, plugin, utils, COMMAND_NAME from .conftest import (run_cmd, normalize, verify_help_text, HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG, complete_tester, odd_file_names) @@ -1258,7 +1258,7 @@ def multiline_app(): return app def test_multiline_complete_empty_statement_raises_exception(multiline_app): - with pytest.raises(cmd2.EmptyStatement): + with pytest.raises(exceptions.EmptyStatement): multiline_app._complete_statement('') def test_multiline_complete_statement_without_terminator(multiline_app): diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 2114bfaa..435f22eb 100755 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -7,7 +7,7 @@ import attr import pytest import cmd2 -from cmd2 import constants, utils +from cmd2 import constants, exceptions, utils from cmd2.parsing import StatementParser, shlex_split @pytest.fixture @@ -588,10 +588,10 @@ def test_parse_unclosed_quotes(parser): def test_empty_statement_raises_exception(): app = cmd2.Cmd() - with pytest.raises(cmd2.EmptyStatement): + with pytest.raises(exceptions.EmptyStatement): app._complete_statement('') - with pytest.raises(cmd2.EmptyStatement): + with pytest.raises(exceptions.EmptyStatement): app._complete_statement(' ') @pytest.mark.parametrize('line,command,args', [ diff --git a/tests/test_plugin.py b/tests/test_plugin.py index f7065db5..c118b60d 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -14,7 +14,7 @@ except ImportError: from unittest import mock import cmd2 -from cmd2 import plugin +from cmd2 import exceptions, plugin class Plugin: @@ -81,7 +81,7 @@ class Plugin: def postparse_hook_emptystatement(self, data: cmd2.plugin.PostparsingData) -> cmd2.plugin.PostparsingData: """A postparsing hook with raises an EmptyStatement exception""" self.called_postparsing += 1 - raise cmd2.EmptyStatement + raise exceptions.EmptyStatement def postparse_hook_exception(self, data: cmd2.plugin.PostparsingData) -> cmd2.plugin.PostparsingData: """A postparsing hook which raises an exception""" @@ -126,7 +126,7 @@ class Plugin: def precmd_hook_emptystatement(self, data: plugin.PrecommandData) -> plugin.PrecommandData: """A precommand hook which raises an EmptyStatement exception""" self.called_precmd += 1 - raise cmd2.EmptyStatement + raise exceptions.EmptyStatement def precmd_hook_exception(self, data: plugin.PrecommandData) -> plugin.PrecommandData: """A precommand hook which raises an exception""" -- cgit v1.2.1