@@ -173,11 +173,22 @@ def test_file_providers(
173
173
174
174
175
175
@pytest .mark .parametrize (
176
- "tag_format,tag,version " ,
176
+ "tag_format,tag,expected_version " ,
177
177
(
178
+ # If tag_format is None, version_scheme.parser is used.
179
+ # Its DEFAULT_VERSION_PARSER allows a v prefix, but matches PEP440 otherwise.
178
180
(None , "0.1.0" , "0.1.0" ),
179
181
(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" ),
180
189
("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" ),
181
192
("version-$version" , "version-0.1.0" , "0.1.0" ),
182
193
("version-$version" , "version-0.1" , "0.1" ),
183
194
("version-$version" , "version-0.1.0rc1" , "0.1.0rc1" ),
@@ -191,7 +202,7 @@ def test_file_providers(
191
202
)
192
203
@pytest .mark .usefixtures ("tmp_git_project" )
193
204
def 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
195
206
):
196
207
create_file_and_commit ("test: fake commit" )
197
208
create_tag (tag )
@@ -203,25 +214,13 @@ def test_scm_provider(
203
214
204
215
provider = get_provider (config )
205
216
assert isinstance (provider , ScmProvider )
206
- assert provider .get_version () == version
217
+ actual_version = provider .get_version ()
218
+ assert actual_version == expected_version
207
219
208
220
# Should not fail on set_version()
209
221
provider .set_version ("43.1" )
210
222
211
223
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
-
225
224
@pytest .mark .usefixtures ("tmp_git_project" )
226
225
def test_scm_provider_default_without_commits_and_tags (config : BaseConfig ):
227
226
config .settings ["version_provider" ] = "scm"
0 commit comments