Skip to content

Commit 118f850

Browse files
committed
fix: improve test fixtures and assertions
These changes enhance the mock home directory setup and add assertions to verify the output of the system under test, ensuring that the tests accurately reflect the expected behavior.
1 parent 6193d6d commit 118f850

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def mock_config():
3232
@pytest.fixture
3333
def mock_home_dir(tmp_path):
3434
"""Mock home directory"""
35-
with patch("pathlib.Path.home", return_value=tmp_path):
36-
yield tmp_path
35+
home = tmp_path / "home"
36+
with patch("pathlib.Path.home", return_value=home):
37+
yield home
3738

3839
@pytest.fixture
3940
def mock_repo(tmp_path):

tests/test_system.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_no_config_file(capsys, mock_repo, mock_home_dir):
5757
assert e.value.code == 0
5858
captured = capsys.readouterr()
5959
assert "Please check and update your configuration file." in captured.out
60+
assert "Auto created configuration file in" in captured.out
6061

6162
def test_auto_create_config(capsys, mock_repo, mock_home_dir):
6263
"""Test no configuration file"""
@@ -66,9 +67,7 @@ def test_auto_create_config(capsys, mock_repo, mock_home_dir):
6667
with pytest.raises(SystemExit) as e:
6768
AiCommit(mock_repo).run()
6869
assert e.value.code == 0
69-
#captured = capsys.readouterr()
70-
#assert "Please check and update your configuration file." in captured.out
71-
#assert "Auto created configuration file in" in captured.out
70+
7271
assert config_file.exists()
7372
assert "[openai]" in config_file.read_text()
7473
assert "api_key = your-api-key-here" in config_file.read_text()
@@ -79,7 +78,7 @@ def test_read_global_config(capsys, mock_repo, mock_home_dir):
7978
"""Test reading global configuration file"""
8079
config_file = mock_home_dir / ".config/aicmt/.aicmtrc"
8180
assert not config_file.exists()
82-
81+
8382
config_dir = mock_home_dir / ".config/aicmt"
8483
config_content = """
8584
[openai]

0 commit comments

Comments
 (0)