From: Mike Bayer Date: Wed, 16 Jun 2021 17:39:03 +0000 (-0400) Subject: repair py2k support X-Git-Tag: rel_1_7_0~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01b5e5fa08c646d3d1f65c731136a1a6a9255315;p=thirdparty%2Fsqlalchemy%2Falembic.git repair py2k support the editor patch had some py3 isms as a result of us disabling the python 2 tests in gerrit. need to move forward w/ the py3k or re-enable py2k Change-Id: If47b0ebc105131fd3e7b8e6d76e0555da1484b8c --- diff --git a/alembic/util/editor.py b/alembic/util/editor.py index c27f0f36..51041489 100644 --- a/alembic/util/editor.py +++ b/alembic/util/editor.py @@ -5,6 +5,7 @@ from os.path import splitext from subprocess import check_call from .compat import is_posix +from .compat import raise_ from .exc import CommandError @@ -27,7 +28,7 @@ def open_in_editor(filename, environ=None): editor = _find_editor(environ) check_call([editor, filename]) except Exception as exc: - raise CommandError("Error executing editor (%s)" % (exc,)) from exc + raise_(CommandError("Error executing editor (%s)" % (exc,)), from_=exc) def _find_editor(environ=None): diff --git a/tests/test_editor.py b/tests/test_editor.py index 0ec6f5f4..4a58b8fb 100644 --- a/tests/test_editor.py +++ b/tests/test_editor.py @@ -1,21 +1,23 @@ import os from os.path import join -from unittest.mock import patch from alembic import util from alembic.testing import combinations from alembic.testing import expect_raises_message +from alembic.testing import mock from alembic.testing.fixtures import TestBase class TestHelpers(TestBase): def common(self, cb, is_posix=True): - with patch("alembic.util.editor.check_call") as check_call, patch( + with mock.patch( + "alembic.util.editor.check_call" + ) as check_call, mock.patch( "alembic.util.editor.exists" - ) as exists, patch( + ) as exists, mock.patch( "alembic.util.editor.is_posix", new=is_posix, - ), patch( + ), mock.patch( "os.pathsep", new=":" if is_posix else ";" ): cb(check_call, exists)