diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2021-06-23 18:32:24 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-06-23 18:32:24 +0000 |
commit | 64c9edf283520c38738e240fc011ce963c8bd9c5 (patch) | |
tree | 6255acdefa736bcc5b34c857e3e97f930f700636 /tests | |
parent | 56a21371e7d9c5db22632e1481c3ca91e6733b8e (diff) | |
parent | d7d358e4ca5e4eab69f2d6e983aa8d026a776ae3 (diff) | |
download | alembic-64c9edf283520c38738e240fc011ce963c8bd9c5.tar.gz |
Merge "Support version_locations paths with spaces"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_config.py | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/tests/test_config.py b/tests/test_config.py index 3b2e957..fdb837e 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,7 +1,9 @@ #!coding: utf-8 - +import os +import tempfile from alembic import config +from alembic import testing from alembic import util from alembic.migration import MigrationContext from alembic.operations import Operations @@ -9,6 +11,7 @@ from alembic.script import ScriptDirectory from alembic.testing import assert_raises_message from alembic.testing import eq_ from alembic.testing import mock +from alembic.testing.assertions import expect_raises_message from alembic.testing.env import _no_sql_testing_config from alembic.testing.env import _write_config_file from alembic.testing.env import clear_staging_env @@ -108,6 +111,91 @@ class ConfigTest(TestBase): cfg.attributes["connection"] = m2 eq_(cfg.attributes, {"m1": m1, "connection": m2}) + @testing.combinations( + ( + "legacy raw string 1", + None, + "/foo", + ["/foo"], + ), + ( + "legacy raw string 2", + None, + "/foo /bar", + ["/foo", "/bar"], + ), + ( + "legacy raw string 3", + "space", + "/foo", + ["/foo"], + ), + ( + "legacy raw string 4", + "space", + "/foo /bar", + ["/foo", "/bar"], + ), + ( + "Linux pathsep 1", + ":", + "/Project A", + ["/Project A"], + ), + ( + "Linux pathsep 2", + ":", + "/Project A:/Project B", + ["/Project A", "/Project B"], + ), + ( + "Windows pathsep 1", + ";", + r"C:\Project A", + [r"C:\Project A"], + ), + ( + "Windows pathsep 2", + ";", + r"C:\Project A;C:\Project B", + [r"C:\Project A", r"C:\Project B"], + ), + ( + "os pathsep", + "os", + r"path_number_one%(sep)spath_number_two%(sep)s" + % {"sep": os.pathsep}, + [r"path_number_one", r"path_number_two"], + ), + ( + "invalid pathsep 2", + "|", + "/foo|/bar", + ValueError( + "'|' is not a valid value for version_path_separator; " + "expected 'space', 'os', ':', ';'" + ), + ), + id_="iaaa", + argnames="separator, string_value, expected_result", + ) + def test_version_locations(self, separator, string_value, expected_result): + cfg = config.Config() + if separator is not None: + cfg.set_main_option( + "version_path_separator", + separator, + ) + cfg.set_main_option("script_location", tempfile.gettempdir()) + cfg.set_main_option("version_locations", string_value) + + if isinstance(expected_result, ValueError): + with expect_raises_message(ValueError, expected_result.args[0]): + ScriptDirectory.from_config(cfg) + else: + s = ScriptDirectory.from_config(cfg) + eq_(s.version_locations, expected_result) + class StdoutOutputEncodingTest(TestBase): def test_plain(self): |