@@ -173,11 +173,22 @@ def test_file_providers(
173173
174174
175175@pytest .mark .parametrize (
176- "tag_format,tag,version " ,
176+ "tag_format,tag,expected_version " ,
177177 (
178+ # If tag_format is None, version_scheme.parser is used.
179+ # Its DEFAULT_VERSION_PARSER allows a v prefix, but matches PEP440 otherwise.
178180 (None , "0.1.0" , "0.1.0" ),
179181 (None , "v0.1.0" , "0.1.0" ),
182+ (None , "no-match-because-version-scheme-is-strict" , "0.0.0" ),
183+ # If tag_format is not None, TAG_FORMAT_REGEXS are used, which are much more
184+ # lenient.
185+ ("$version" , "match-TAG_FORMAT_REGEXS" , "match-TAG_FORMAT_REGEXS" ),
186+ ("$version" , "0.1.0" , "0.1.0" ),
187+ ("$version" , "v0.1.0" , "0.1.0" ),
188+ ("$version" , "v-0.1.0" , "0.1.0" ),
180189 ("v$version" , "v0.1.0" , "0.1.0" ),
190+ ("v$version" , "no-match-because-no-v-prefix" , "0.0.0" ),
191+ ("v$version" , "v-match-TAG_FORMAT_REGEXS" , "-match-TAG_FORMAT_REGEXS" ),
181192 ("version-$version" , "version-0.1.0" , "0.1.0" ),
182193 ("version-$version" , "version-0.1" , "0.1" ),
183194 ("version-$version" , "version-0.1.0rc1" , "0.1.0rc1" ),
@@ -191,7 +202,7 @@ def test_file_providers(
191202)
192203@pytest .mark .usefixtures ("tmp_git_project" )
193204def test_scm_provider (
194- config : BaseConfig , tag_format : str | None , tag : str , version : str
205+ config : BaseConfig , tag_format : str | None , tag : str , expected_version : str
195206):
196207 create_file_and_commit ("test: fake commit" )
197208 create_tag (tag )
@@ -203,25 +214,13 @@ def test_scm_provider(
203214
204215 provider = get_provider (config )
205216 assert isinstance (provider , ScmProvider )
206- assert provider .get_version () == version
217+ actual_version = provider .get_version ()
218+ assert actual_version == expected_version
207219
208220 # Should not fail on set_version()
209221 provider .set_version ("43.1" )
210222
211223
212- @pytest .mark .usefixtures ("tmp_git_project" )
213- def test_scm_provider_default_without_matching_tag (config : BaseConfig ):
214- create_file_and_commit ("test: fake commit" )
215- create_tag ("should-not-match" )
216- create_file_and_commit ("test: fake commit" )
217-
218- config .settings ["version_provider" ] = "scm"
219-
220- provider = get_provider (config )
221- assert isinstance (provider , ScmProvider )
222- assert provider .get_version () == "0.0.0"
223-
224-
225224@pytest .mark .usefixtures ("tmp_git_project" )
226225def test_scm_provider_default_without_commits_and_tags (config : BaseConfig ):
227226 config .settings ["version_provider" ] = "scm"
0 commit comments