|
8 | 8 |
|
9 | 9 | import pytest
|
10 | 10 |
|
| 11 | +from setuptools_scm import Configuration |
| 12 | +from setuptools_scm import format_version |
11 | 13 | from setuptools_scm import git
|
12 | 14 | from setuptools_scm import integration
|
13 | 15 | from setuptools_scm import NonNormalizedVersion
|
14 | 16 | from setuptools_scm.file_finder_git import git_find_files
|
| 17 | +from setuptools_scm.git import archival_to_version |
15 | 18 | from setuptools_scm.utils import do
|
16 | 19 | from setuptools_scm.utils import has_command
|
17 | 20 |
|
@@ -392,10 +395,39 @@ def parse_date():
|
392 | 395 | assert meta.node_date == today
|
393 | 396 |
|
394 | 397 |
|
395 |
| -def test_git_getdate_badgit( |
396 |
| - wd, |
397 |
| -): |
| 398 | +def test_git_getdate_badgit(wd): |
398 | 399 | wd.commit_testfile()
|
399 | 400 | git_wd = git.GitWorkdir(os.fspath(wd.cwd))
|
400 | 401 | with patch.object(git_wd, "do_ex", Mock(return_value=("%cI", "", 0))):
|
401 | 402 | assert git_wd.get_head_date() is None
|
| 403 | + |
| 404 | + |
| 405 | +@pytest.mark.parametrize( |
| 406 | + "expected, from_data", |
| 407 | + [ |
| 408 | + ( |
| 409 | + "1.0", |
| 410 | + {"describe-name": "1.0-0-g0000"}, |
| 411 | + ), |
| 412 | + ( |
| 413 | + "1.1.dev3+g0000", |
| 414 | + { |
| 415 | + "describe-name": "1.0-3-g0000", |
| 416 | + "node": "0" * 20, |
| 417 | + }, |
| 418 | + ), |
| 419 | + ("0.0", {"node": "0" * 20}), |
| 420 | + ("1.2.2", {"describe-name": "release-1.2.2-0-g00000"}), |
| 421 | + ("1.2.2.dev0", {"ref-names": "tag: release-1.2.2.dev"}), |
| 422 | + ], |
| 423 | +) |
| 424 | +@pytest.mark.filterwarnings("ignore:git archive did not support describe output") |
| 425 | +def test_git_archival_to_version(expected, from_data): |
| 426 | + config = Configuration() |
| 427 | + version = archival_to_version(from_data, config=config) |
| 428 | + assert ( |
| 429 | + format_version( |
| 430 | + version, version_scheme="guess-next-dev", local_scheme="node-and-date" |
| 431 | + ) |
| 432 | + == expected |
| 433 | + ) |
0 commit comments