Skip to content

Commit 98fb3c9

Browse files
committed
clean up unit tests
1 parent 1130c70 commit 98fb3c9

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

.generator/test_cli.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@ def test_handle_build_dry_run():
5454
def test_read_valid_json(mocker):
5555
"""Tests reading a valid JSON file."""
5656
mock_content = '{"key": "value"}'
57-
mocker.patch("os.path.exists", return_value=True)
5857
mocker.patch("builtins.open", mocker.mock_open(read_data=mock_content))
5958
result = _read_json_file("fake/path.json")
6059
assert result == {"key": "value"}
6160

6261

6362
def test_file_not_found(mocker):
6463
"""Tests behavior when the file does not exist."""
65-
mocker.patch("os.path.exists", return_value=False)
64+
mocker.patch("builtins.open", side_effect=FileNotFoundError("No such file"))
6665

6766
with pytest.raises(FileNotFoundError):
6867
_read_json_file("non/existent/path.json")
@@ -71,19 +70,7 @@ def test_file_not_found(mocker):
7170
def test_invalid_json(mocker):
7271
"""Tests reading a file with malformed JSON."""
7372
mock_content = '{"key": "value",}'
74-
mocker.patch("os.path.exists", return_value=True)
7573
mocker.patch("builtins.open", mocker.mock_open(read_data=mock_content))
7674

7775
with pytest.raises(json.JSONDecodeError):
7876
_read_json_file("fake/path.json")
79-
80-
81-
def test_io_error_on_read(mocker):
82-
"""Tests for a generic IOError."""
83-
mocker.patch("os.path.exists", return_value=True)
84-
mocked_open = mocker.mock_open()
85-
mocked_open.side_effect = IOError("permission denied")
86-
mocker.patch("builtins.open", mocked_open)
87-
88-
with pytest.raises(IOError):
89-
_read_json_file("fake/path.json")

0 commit comments

Comments
 (0)