From 7756b35e23ec11b64a1ac37afcb41dda3ca29913 Mon Sep 17 00:00:00 2001 From: CaselIT Date: Tue, 15 Jun 2021 22:32:05 +0200 Subject: Revendor editor and make dateutil optional Re-implemented the ``python-editor`` dependency as a small internal function to avoid the need for external dependencies. The implementation is based on the original version in 7b91b325ff43a0e9235e0f15b57391fa92352626. Make the ``python-dateutil`` library an optional dependency. This library is only required if the ``timezone`` option is used in the Alembic configuration. An extra require named ``tz`` is available with ``pip install alembic[tz]`` to install it. Fixes: #674 Fixes: #856 Change-Id: I07f17b2fea01e3a3d677ce95333fe3e8d8d438fd --- tests/test_command.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'tests/test_command.py') diff --git a/tests/test_command.py b/tests/test_command.py index 4114be0..a477a1d 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -11,12 +11,10 @@ from sqlalchemy import text from alembic import __version__ from alembic import command from alembic import config -from alembic import testing from alembic import util from alembic.script import ScriptDirectory from alembic.testing import assert_raises from alembic.testing import assert_raises_message -from alembic.testing import config as testing_config from alembic.testing import eq_ from alembic.testing import is_false from alembic.testing import is_true @@ -924,7 +922,7 @@ class EditTest(TestBase): % (EditTest.cfg.config_args["here"], EditTest.c) ) - with mock.patch("alembic.util.edit") as edit: + with mock.patch("alembic.util.open_in_editor") as edit: command.edit(self.cfg, "head") edit.assert_called_with(expected_call_arg) @@ -934,22 +932,10 @@ class EditTest(TestBase): % (EditTest.cfg.config_args["here"], EditTest.b) ) - with mock.patch("alembic.util.edit") as edit: + with mock.patch("alembic.util.open_in_editor") as edit: command.edit(self.cfg, self.b[0:3]) edit.assert_called_with(expected_call_arg) - @testing_config.requirements.editor_installed - @testing.emits_python_deprecation_warning("the imp module is deprecated") - def test_edit_with_missing_editor(self): - with mock.patch("editor.edit") as edit_mock: - edit_mock.side_effect = OSError("file not found") - assert_raises_message( - util.CommandError, - "file not found", - util.edit, - "/not/a/file.txt", - ) - def test_edit_no_revs(self): assert_raises_message( util.CommandError, @@ -975,7 +961,7 @@ class EditTest(TestBase): ) command.stamp(self.cfg, self.b) - with mock.patch("alembic.util.edit") as edit: + with mock.patch("alembic.util.open_in_editor") as edit: command.edit(self.cfg, "current") edit.assert_called_with(expected_call_arg) -- cgit v1.2.1