Skip to content

Commit 2e52804

Browse files
committed
actually FIX the version command test for real this time
1 parent 9219886 commit 2e52804

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

tests/cli/commands/test_version.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ def test_version_command_success(mock_file_open, mock_exists, mock_get_translati
3030
mock_get_translation.return_value = DUMMY_MESSAGES
3131
mock_exists.return_value = True
3232

33-
# Setup mock file content with proper line structure
34-
setup_content = 'version="1.2.3",\nname="spicecode"'
35-
mock_file_open.return_value.read.return_value = setup_content
36-
mock_file_open.return_value.__iter__.return_value = iter(setup_content.splitlines())
33+
# Setup mock file content - each line should end with \n for proper line iteration
34+
file_lines = [
35+
'name="spicecode",\n',
36+
'version="1.2.3",\n',
37+
'author="test"\n'
38+
]
39+
mock_file_open.return_value.__iter__.return_value = iter(file_lines)
3740

3841
version_command(LANG_FILE="dummy_lang.txt", CURRENT_DIR=TEST_CURRENT_DIR)
3942

@@ -51,10 +54,13 @@ def test_version_command_version_not_in_setup(mock_file_open, mock_exists, mock_
5154
mock_get_translation.return_value = DUMMY_MESSAGES
5255
mock_exists.return_value = True
5356

54-
# Setup mock file content without version
55-
setup_content = 'name="spicecode"\nauthor="test"'
56-
mock_file_open.return_value.read.return_value = setup_content
57-
mock_file_open.return_value.__iter__.return_value = iter(setup_content.splitlines())
57+
# Setup mock file content without version line
58+
file_lines = [
59+
'name="spicecode",\n',
60+
'author="test",\n',
61+
'description="A CLI tool"\n'
62+
]
63+
mock_file_open.return_value.__iter__.return_value = iter(file_lines)
5864

5965
version_command(LANG_FILE="dummy_lang.txt", CURRENT_DIR=TEST_CURRENT_DIR)
6066

0 commit comments

Comments
 (0)