Skip to content

Commit 7a4cdf6

Browse files
test: Some cleanup and fix if CWD not project root
1 parent 38daf5e commit 7a4cdf6

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

tests/test_changelog.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pathlib import Path
2+
13
import pytest
24

35
from commitizen import changelog, defaults, git
@@ -495,7 +497,7 @@ def tags() -> list:
495497

496498
@pytest.fixture
497499
def changelog_content() -> str:
498-
changelog_path = "tests/CHANGELOG_FOR_TEST.md"
500+
changelog_path = Path(__file__).parent / "CHANGELOG_FOR_TEST.md"
499501
with open(changelog_path, "r") as f:
500502
return f.read()
501503

tests/test_conf.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import os
32
from pathlib import Path
43

54
import pytest
@@ -41,7 +40,7 @@
4140
}
4241

4342

44-
_settings = {
43+
_read_settings = {
4544
"name": "cz_jira",
4645
"version": "1.0.0",
4746
"tag_format": "$version",
@@ -79,16 +78,6 @@
7978
"prerelease_offset": 0,
8079
}
8180

82-
_read_settings = {
83-
"name": "cz_jira",
84-
"version": "1.0.0",
85-
"version_files": ["commitizen/__version__.py", "pyproject.toml"],
86-
"style": [["pointer", "reverse"], ["question", "underline"]],
87-
"changelog_file": "CHANGELOG.md",
88-
"pre_bump_hooks": ["scripts/generate_documentation.sh"],
89-
"post_bump_hooks": ["scripts/slack_notification.sh"],
90-
}
91-
9281

9382
@pytest.fixture
9483
def config_files_manager(request, tmpdir):
@@ -105,7 +94,7 @@ def config_files_manager(request, tmpdir):
10594

10695

10796
def test_find_git_project_root(tmpdir):
108-
assert git.find_git_project_root() == Path(os.getcwd())
97+
assert git.find_git_project_root() == Path(__file__).parent.parent
10998

11099
with tmpdir.as_cwd() as _:
111100
assert git.find_git_project_root() is None
@@ -127,7 +116,7 @@ class TestReadCfg:
127116
)
128117
def test_load_conf(_, config_files_manager):
129118
cfg = config.read_cfg()
130-
assert cfg.settings == _settings
119+
assert cfg.settings == _read_settings
131120

132121
def test_conf_returns_default_when_no_files(_, tmpdir):
133122
with tmpdir.as_cwd():
@@ -142,7 +131,7 @@ def test_load_empty_pyproject_toml_and_cz_toml_with_config(_, tmpdir):
142131
p.write(PYPROJECT)
143132

144133
cfg = config.read_cfg()
145-
assert cfg.settings == _settings
134+
assert cfg.settings == _read_settings
146135

147136

148137
class TestTomlConfig:

0 commit comments

Comments
 (0)