Skip to content

Commit 164724d

Browse files
committed
test(snapshots): provide a test:regen command to regenerate all snapshots, including those depending on Python version
1 parent 9f11285 commit 164724d

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

docs/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ If you're a first-time contributor, please check out issues labeled [good first
6464
- Run the full test suite: `poetry all`
6565
- Ensure test coverage doesn't drop (we use [CodeCov](https://app.codecov.io/gh/commitizen-tools/commitizen))
6666
- For documentation changes, run `poetry doc` to check for warnings/errors
67+
- If you need to change some file regression snapshots, run: `poetry test:regen`
6768
4. **Committing Changes**
6869
- Use Commitizen to make commits (we follow [conventional commits](https://www.conventionalcommits.org/))
6970
- Example: `cz commit`

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ test.cmd = "pytest -n 3 --dist=loadfile"
264264
"test:all".help = "Run the test suite on all supported Python versions"
265265
"test:all".cmd = "tox --parallel"
266266

267+
"test:regen".help = "Regenerate the test fixtures"
268+
"test:regen".parallel = [
269+
{ ref = "test -k 'not py_' --regen-all" },
270+
{ ref = "test:all -- -k py_ --regen-all" },
271+
]
272+
267273
cover.help = "Run the test suite with coverage"
268274
cover.ref = "test --cov-report term-missing --cov-report=xml:coverage.xml --cov=commitizen"
269275

tests/commands/test_common_command.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
from commitizen.commands import Example, Info, ListCz, Schema
88

99

10-
@pytest.mark.skipif(
11-
sys.version_info < (3, 13),
12-
reason="The output message of argparse is different between Python 3.13 and lower than Python 3.13",
13-
)
1410
@pytest.mark.parametrize(
1511
"command",
1612
[
@@ -26,6 +22,7 @@
2622
"version",
2723
],
2824
)
25+
@pytest.mark.usefixtures("python_version")
2926
def test_command_shows_description_when_use_help_option(
3027
mocker: MockFixture,
3128
capsys,

tests/conftest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import os
44
import re
5+
import sys
56
import tempfile
67
from pathlib import Path
7-
from typing import TYPE_CHECKING
8+
from typing import TYPE_CHECKING, cast
89

910
import pytest
1011

@@ -28,6 +29,7 @@
2829

2930
SIGNER = "GitHub Action"
3031
SIGNER_MAIL = "[email protected]"
32+
PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
3133

3234

3335
@pytest.fixture
@@ -290,3 +292,9 @@ def any_changelog_format(config: BaseConfig) -> ChangelogFormat:
290292
"""For test not relying on formats specifics, use the default"""
291293
config.settings["changelog_format"] = defaults.CHANGELOG_FORMAT
292294
return get_changelog_format(config)
295+
296+
297+
@pytest.fixture(params=[pytest.param(PYTHON_VERSION, id=f"py_{PYTHON_VERSION}")])
298+
def python_version(request: pytest.FixtureRequest) -> str:
299+
"""The current python version in '{major}.{minor}' format"""
300+
return cast("str", request.param)

0 commit comments

Comments
 (0)