From e38aa65cae8be7336728935083d417b0e1f581b3 Mon Sep 17 00:00:00 2001 From: ohemorange Date: Mon, 11 Nov 2019 10:19:28 -0800 Subject: [PATCH] Move items in certbot/display to _internal (#7532) * Move display/completer.py to _internal/ * Move display/dummy_readline.py to _internal/ * Move display/enhancements.py to _internal/ * Create __init__.py in _internal/display --- certbot/_internal/client.py | 2 +- certbot/_internal/display/__init__.py | 1 + certbot/{ => _internal}/display/completer.py | 2 +- .../{ => _internal}/display/dummy_readline.py | 0 certbot/{ => _internal}/display/enhancements.py | 0 certbot/display/util.py | 2 +- certbot/tests/display/completer_test.py | 16 ++++++++-------- certbot/tests/display/enhancements_test.py | 12 ++++++------ docs/api/display.rst | 6 ------ 9 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 certbot/_internal/display/__init__.py rename certbot/{ => _internal}/display/completer.py (96%) rename certbot/{ => _internal}/display/dummy_readline.py (100%) rename certbot/{ => _internal}/display/enhancements.py (100%) diff --git a/certbot/_internal/client.py b/certbot/_internal/client.py index 7a0daf77b..3ecd2edf0 100644 --- a/certbot/_internal/client.py +++ b/certbot/_internal/client.py @@ -30,7 +30,7 @@ from certbot import interfaces from certbot._internal import storage from certbot import util from certbot.compat import os -from certbot.display import enhancements +from certbot._internal.display import enhancements from certbot.display import ops as display_ops from certbot.plugins import selection as plugin_selection diff --git a/certbot/_internal/display/__init__.py b/certbot/_internal/display/__init__.py new file mode 100644 index 000000000..9d39dce92 --- /dev/null +++ b/certbot/_internal/display/__init__.py @@ -0,0 +1 @@ +"""Certbot display utilities.""" diff --git a/certbot/display/completer.py b/certbot/_internal/display/completer.py similarity index 96% rename from certbot/display/completer.py rename to certbot/_internal/display/completer.py index 509a1051a..3be06bec1 100644 --- a/certbot/display/completer.py +++ b/certbot/_internal/display/completer.py @@ -4,7 +4,7 @@ import glob try: import readline except ImportError: - import certbot.display.dummy_readline as readline # type: ignore + import certbot._internal.display.dummy_readline as readline # type: ignore class Completer(object): diff --git a/certbot/display/dummy_readline.py b/certbot/_internal/display/dummy_readline.py similarity index 100% rename from certbot/display/dummy_readline.py rename to certbot/_internal/display/dummy_readline.py diff --git a/certbot/display/enhancements.py b/certbot/_internal/display/enhancements.py similarity index 100% rename from certbot/display/enhancements.py rename to certbot/_internal/display/enhancements.py diff --git a/certbot/display/util.py b/certbot/display/util.py index aa9f0583b..d67e33dc8 100644 --- a/certbot/display/util.py +++ b/certbot/display/util.py @@ -10,7 +10,7 @@ from certbot import errors from certbot import interfaces from certbot.compat import misc from certbot.compat import os -from certbot.display import completer +from certbot._internal.display import completer logger = logging.getLogger(__name__) diff --git a/certbot/tests/display/completer_test.py b/certbot/tests/display/completer_test.py index 73d17946e..262e0b344 100644 --- a/certbot/tests/display/completer_test.py +++ b/certbot/tests/display/completer_test.py @@ -1,8 +1,8 @@ -"""Test certbot.display.completer.""" +"""Test certbot._internal.display.completer.""" try: import readline # pylint: disable=import-error except ImportError: - import certbot.display.dummy_readline as readline # type: ignore + import certbot._internal.display.dummy_readline as readline # type: ignore import string import sys import unittest @@ -18,7 +18,7 @@ import certbot.tests.util as test_util # pylint: disable=ungrouped-imports class CompleterTest(test_util.TempDirTestCase): - """Test certbot.display.completer.Completer.""" + """Test certbot._internal.display.completer.Completer.""" def setUp(self): super(CompleterTest, self).setUp() @@ -40,7 +40,7 @@ class CompleterTest(test_util.TempDirTestCase): pass def test_complete(self): - from certbot.display import completer + from certbot._internal.display import completer my_completer = completer.Completer() num_paths = len(self.paths) @@ -64,7 +64,7 @@ class CompleterTest(test_util.TempDirTestCase): sys.modules['readline'] = original_readline def test_context_manager_with_unmocked_readline(self): - from certbot.display import completer + from certbot._internal.display import completer reload_module(completer) original_completer = readline.get_completer() @@ -76,18 +76,18 @@ class CompleterTest(test_util.TempDirTestCase): self.assertEqual(readline.get_completer(), original_completer) self.assertEqual(readline.get_completer_delims(), original_delims) - @mock.patch('certbot.display.completer.readline', autospec=True) + @mock.patch('certbot._internal.display.completer.readline', autospec=True) def test_context_manager_libedit(self, mock_readline): mock_readline.__doc__ = 'libedit' self._test_context_manager_with_mock_readline(mock_readline) - @mock.patch('certbot.display.completer.readline', autospec=True) + @mock.patch('certbot._internal.display.completer.readline', autospec=True) def test_context_manager_readline(self, mock_readline): mock_readline.__doc__ = 'GNU readline' self._test_context_manager_with_mock_readline(mock_readline) def _test_context_manager_with_mock_readline(self, mock_readline): - from certbot.display import completer + from certbot._internal.display import completer mock_readline.parse_and_bind.side_effect = enable_tab_completion diff --git a/certbot/tests/display/enhancements_test.py b/certbot/tests/display/enhancements_test.py index b8321d940..edace29b1 100644 --- a/certbot/tests/display/enhancements_test.py +++ b/certbot/tests/display/enhancements_test.py @@ -18,10 +18,10 @@ class AskTest(unittest.TestCase): @classmethod def _call(cls, enhancement): - from certbot.display.enhancements import ask + from certbot._internal.display.enhancements import ask return ask(enhancement) - @mock.patch("certbot.display.enhancements.util") + @mock.patch("certbot._internal.display.enhancements.util") def test_redirect(self, mock_util): mock_util().menu.return_value = (display_util.OK, 1) self.assertTrue(self._call("redirect")) @@ -34,20 +34,20 @@ class RedirectTest(unittest.TestCase): """Test the redirect_by_default method.""" @classmethod def _call(cls): - from certbot.display.enhancements import redirect_by_default + from certbot._internal.display.enhancements import redirect_by_default return redirect_by_default() - @mock.patch("certbot.display.enhancements.util") + @mock.patch("certbot._internal.display.enhancements.util") def test_secure(self, mock_util): mock_util().menu.return_value = (display_util.OK, 1) self.assertTrue(self._call()) - @mock.patch("certbot.display.enhancements.util") + @mock.patch("certbot._internal.display.enhancements.util") def test_cancel(self, mock_util): mock_util().menu.return_value = (display_util.CANCEL, 1) self.assertFalse(self._call()) - @mock.patch("certbot.display.enhancements.util") + @mock.patch("certbot._internal.display.enhancements.util") def test_easy(self, mock_util): mock_util().menu.return_value = (display_util.OK, 0) self.assertFalse(self._call()) diff --git a/docs/api/display.rst b/docs/api/display.rst index 1a18e6534..70038786c 100644 --- a/docs/api/display.rst +++ b/docs/api/display.rst @@ -15,9 +15,3 @@ .. automodule:: certbot.display.ops :members: - -:mod:`certbot.display.enhancements` -======================================= - -.. automodule:: certbot.display.enhancements - :members: