@@ -293,3 +293,61 @@ def test_has_command_logs_stderr(caplog: pytest.LogCaptureFixture) -> None:
293
293
def test_tag_to_version (tag : str , expected_version : str ) -> None :
294
294
version = str (tag_to_version (tag , c ))
295
295
assert version == expected_version
296
+
297
+
298
+ def test_write_version_to_path_deprecation_warning_none (tmp_path : Path ) -> None :
299
+ """Test that write_version_to_path warns when scm_version=None is passed."""
300
+ from setuptools_scm ._integration .dump_version import write_version_to_path
301
+
302
+ target_file = tmp_path / "version.py"
303
+
304
+ # This should raise a deprecation warning when scm_version=None is explicitly passed
305
+ with pytest .warns (
306
+ DeprecationWarning , match = "write_version_to_path called without scm_version"
307
+ ):
308
+ write_version_to_path (
309
+ target = target_file ,
310
+ template = None , # Use default template
311
+ version = "1.2.3" ,
312
+ scm_version = None , # Explicitly passing None should warn
313
+ )
314
+
315
+ # Verify the file was created and contains the expected content
316
+ assert target_file .exists ()
317
+ content = target_file .read_text (encoding = "utf-8" )
318
+
319
+ # Check that the version is correctly formatted
320
+ assert "__version__ = version = '1.2.3'" in content
321
+ assert "__version_tuple__ = version_tuple = (1, 2, 3)" in content
322
+
323
+ # Check that commit_id is set to None when scm_version is None
324
+ assert "__commit_id__ = commit_id = None" in content
325
+
326
+
327
+ def test_write_version_to_path_deprecation_warning_missing (tmp_path : Path ) -> None :
328
+ """Test that write_version_to_path warns when scm_version parameter is not provided."""
329
+ from setuptools_scm ._integration .dump_version import write_version_to_path
330
+
331
+ target_file = tmp_path / "version.py"
332
+
333
+ # This should raise a deprecation warning when scm_version is not provided
334
+ with pytest .warns (
335
+ DeprecationWarning , match = "write_version_to_path called without scm_version"
336
+ ):
337
+ write_version_to_path (
338
+ target = target_file ,
339
+ template = None , # Use default template
340
+ version = "1.2.3" ,
341
+ # scm_version not provided - should warn
342
+ )
343
+
344
+ # Verify the file was created and contains the expected content
345
+ assert target_file .exists ()
346
+ content = target_file .read_text (encoding = "utf-8" )
347
+
348
+ # Check that the version is correctly formatted
349
+ assert "__version__ = version = '1.2.3'" in content
350
+ assert "__version_tuple__ = version_tuple = (1, 2, 3)" in content
351
+
352
+ # Check that commit_id is set to None when scm_version is None
353
+ assert "__commit_id__ = commit_id = None" in content
0 commit comments