From a3f6922ea012eda84b814b87eb81c2845410d572 Mon Sep 17 00:00:00 2001 From: Mohammed Alkindi Date: Mon, 10 Aug 2026 16:02:56 +0400 Subject: [PATCH 1/2] test: add coverage for alternate version_path spellings Issue #1366 reported that ``alembic revision --version-path`` rejected a directory that was in fact configured, on Windows, when the drive letter's case differed from the configuration. The matching in ScriptDirectory.generate_revision() moved to pathlib in 1.16.0, which resolved it, but nothing in the suite pinned the behaviour. Confirmed on Windows 11 against a multi-head project whose version locations contain spaces: on 1.19.2 the configured spelling, either drive letter case, and a trailing separator are all accepted. Adds a test asserting the revision lands in the configured directory when the path carries a trailing separator and, where a drive letter exists, when its case is swapped. Swapping the case-insensitive Path comparison for a string comparison fails this test alone and none of the existing ones, so it covers ground the suite did not. Fixes: #1366 --- docs/build/unreleased/1366.rst | 9 +++++++++ tests/test_script_production.py | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 docs/build/unreleased/1366.rst diff --git a/docs/build/unreleased/1366.rst b/docs/build/unreleased/1366.rst new file mode 100644 index 00000000..9e1bfbe6 --- /dev/null +++ b/docs/build/unreleased/1366.rst @@ -0,0 +1,9 @@ +.. change:: + :tags: bug, tests + :tickets: 1366 + + Added test coverage asserting that a ``--version-path`` naming an already + configured version location is accepted however it is spelled, covering a + trailing path separator and, on Windows, the case of the drive letter. The + matching moved to ``pathlib`` in 1.16.0, which resolved the behaviour + reported in :ticket:`1366`; this pins it so it cannot regress. diff --git a/tests/test_script_production.py b/tests/test_script_production.py index e14ace91..0cc5d559 100644 --- a/tests/test_script_production.py +++ b/tests/test_script_production.py @@ -1377,6 +1377,29 @@ def test_multiple_dir_no_bases_version_path(self): ) assert os.access(script.path, os.F_OK) + def test_multiple_dir_no_bases_version_path_alternate_spelling(self): + """Spellings that name the same directory must all be accepted. + + A trailing separator is tested everywhere; on Windows the drive + letter's case is tested too, which is what was reported. + """ + configured = os.path.join(_get_staging_directory(), "model1") + + spellings = [configured + os.sep] + drive, rest = os.path.splitdrive(os.path.abspath(configured)) + if drive: + spellings.append(drive.swapcase() + rest) + + for spelling in spellings: + script = command.revision( + self.cfg, message="x", head="base", version_path=spelling + ) + assert os.access(script.path, os.F_OK) + eq_( + Path(script.path).parent.absolute(), + Path(configured).absolute(), + ) + def test_multiple_dir_chooses_base(self): command.revision( self.cfg, From 2d1f834fc1a59308aa0e3044b0666378c1fc4835 Mon Sep 17 00:00:00 2001 From: Mohammed Alkindi Date: Tue, 11 Aug 2026 09:52:40 +0400 Subject: [PATCH 2/2] docs: drop the changelog entry for the version_path test Review feedback: the change adds no code, so a changelog entry saying a test was added carries nothing a user would act on. --- docs/build/unreleased/1366.rst | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 docs/build/unreleased/1366.rst diff --git a/docs/build/unreleased/1366.rst b/docs/build/unreleased/1366.rst deleted file mode 100644 index 9e1bfbe6..00000000 --- a/docs/build/unreleased/1366.rst +++ /dev/null @@ -1,9 +0,0 @@ -.. change:: - :tags: bug, tests - :tickets: 1366 - - Added test coverage asserting that a ``--version-path`` naming an already - configured version location is accepted however it is spelled, covering a - trailing path separator and, on Windows, the case of the drive letter. The - matching moved to ``pathlib`` in 1.16.0, which resolved the behaviour - reported in :ticket:`1366`; this pins it so it cannot regress.