@@ -24,8 +24,8 @@ def test_should_ignore_file(git_operations):
2424def test_get_staged_files_success (mock_run , git_operations , mock_git_file ):
2525 """Test successful retrieval of staged files."""
2626 mock_run .return_value = MagicMock (
27- stdout = " M file1.py\n M file2.py\n " ,
28- stderr = "" ,
27+ stdout = b " M file1.py\n M file2.py\n " ,
28+ stderr = b "" ,
2929 returncode = 0 ,
3030 )
3131
@@ -41,7 +41,7 @@ def test_get_staged_files_success(mock_run, git_operations, mock_git_file):
4141@patch ("subprocess.run" )
4242def test_get_staged_files_empty (mock_run , git_operations ):
4343 """Test when no files are staged."""
44- mock_run .return_value = MagicMock (stdout = "" , stderr = "" , returncode = 0 )
44+ mock_run .return_value = MagicMock (stdout = b "" , stderr = b "" , returncode = 0 )
4545
4646 files = git_operations .get_staged_files ()
4747
@@ -63,8 +63,8 @@ def test_get_staged_files_error(mock_run, git_operations):
6363def test_get_staged_files_with_renames (mock_run , git_operations ):
6464 """Test handling of renamed files."""
6565 mock_run .return_value = MagicMock (
66- stdout = 'R "old file.py" -> "new file.py"\n ' ,
67- stderr = "" ,
66+ stdout = b 'R "old file.py" -> "new file.py"\n ' ,
67+ stderr = b "" ,
6868 returncode = 0 ,
6969 )
7070
@@ -80,8 +80,8 @@ def test_get_staged_files_with_renames(mock_run, git_operations):
8080def test_get_staged_files_ignores_untracked (mock_run , git_operations ):
8181 """Test that untracked files are ignored."""
8282 mock_run .return_value = MagicMock (
83- stdout = "?? new.py\n M tracked.py\n " ,
84- stderr = "" ,
83+ stdout = b "?? new.py\n M tracked.py\n " ,
84+ stderr = b "" ,
8585 returncode = 0 ,
8686 )
8787
@@ -94,9 +94,9 @@ def test_get_staged_files_ignores_untracked(mock_run, git_operations):
9494
9595def test_get_staged_files_with_spaces (git_operations ):
9696 """Test getting staged files with spaces in paths."""
97- mock_output = "M path with spaces/file.py\n A another path/with spaces.py\n "
97+ mock_output = b "M path with spaces/file.py\n A another path/with spaces.py\n "
9898 with patch ("subprocess.run" ) as mock_run :
99- mock_run .return_value = MagicMock (stdout = mock_output , stderr = "" , returncode = 0 )
99+ mock_run .return_value = MagicMock (stdout = mock_output , stderr = b "" , returncode = 0 )
100100 files = git_operations .get_staged_files ()
101101
102102 assert len (files ) == 2
@@ -106,9 +106,9 @@ def test_get_staged_files_with_spaces(git_operations):
106106
107107def test_get_staged_files_with_special_chars (git_operations ):
108108 """Test getting staged files with special characters."""
109- mock_output = "M path/with-dashes.py\n A path/with_underscores.py\n M path/with.dots.py\n "
109+ mock_output = b "M path/with-dashes.py\n A path/with_underscores.py\n M path/with.dots.py\n "
110110 with patch ("subprocess.run" ) as mock_run :
111- mock_run .return_value = MagicMock (stdout = mock_output , stderr = "" , returncode = 0 )
111+ mock_run .return_value = MagicMock (stdout = mock_output , stderr = b "" , returncode = 0 )
112112 files = git_operations .get_staged_files ()
113113
114114 assert len (files ) == 3
@@ -119,9 +119,9 @@ def test_get_staged_files_with_special_chars(git_operations):
119119
120120def test_get_staged_files_with_unicode (git_operations ):
121121 """Test getting staged files with unicode characters."""
122- mock_output = "M path/with/émoji/🚀.py\n A path/with/áccents/file.py\n "
122+ mock_output = "M path/with/émoji/🚀.py\n A path/with/áccents/file.py\n " . encode ( 'utf-8' )
123123 with patch ("subprocess.run" ) as mock_run :
124- mock_run .return_value = MagicMock (stdout = mock_output , stderr = "" , returncode = 0 )
124+ mock_run .return_value = MagicMock (stdout = mock_output , stderr = b "" , returncode = 0 )
125125 files = git_operations .get_staged_files ()
126126
127127 assert len (files ) == 2
@@ -131,8 +131,8 @@ def test_get_staged_files_with_unicode(git_operations):
131131
132132def test_get_staged_files_with_warnings (git_operations ):
133133 """Test getting staged files with git warnings."""
134- mock_output = "M file.py\n "
135- mock_warning = "warning: CRLF will be replaced by LF in file.py"
134+ mock_output = b "M file.py\n "
135+ mock_warning = b "warning: CRLF will be replaced by LF in file.py"
136136 with patch ("subprocess.run" ) as mock_run :
137137 mock_run .return_value = MagicMock (stdout = mock_output , stderr = mock_warning , returncode = 0 )
138138 files = git_operations .get_staged_files ()
@@ -143,19 +143,19 @@ def test_get_staged_files_with_warnings(git_operations):
143143
144144def test_get_staged_files_with_binary_detection (git_operations ):
145145 """Test getting staged files with binary file detection."""
146- mock_output = "M text.py\n M image.png\n "
146+ mock_output = b "M text.py\n M image.png\n "
147147
148148 def mock_run_side_effect (* args , ** kwargs ):
149149 if args [0 ][0 ] == "git" and args [0 ][1 ] == "status" :
150- return MagicMock (stdout = mock_output , stderr = "" , returncode = 0 )
150+ return MagicMock (stdout = mock_output , stderr = b "" , returncode = 0 )
151151 elif args [0 ][0 ] == "git" and args [0 ][1 ] == "diff" :
152152 # Return binary file indicator for image.png
153153 if "image.png" in args [0 ]:
154- return MagicMock (stdout = "-\t -\t image.png\n " , stderr = "" , returncode = 0 )
155- return MagicMock (stdout = "1\t 1\t text.py\n " , stderr = "" , returncode = 0 )
154+ return MagicMock (stdout = b "-\t -\t image.png\n " , stderr = b "" , returncode = 0 )
155+ return MagicMock (stdout = b "1\t 1\t text.py\n " , stderr = b "" , returncode = 0 )
156156 elif args [0 ][0 ] == "git" and args [0 ][1 ] == "hash-object" :
157- return MagicMock (stdout = "abc123\n " , stderr = "" , returncode = 0 )
158- return MagicMock (stdout = "" , stderr = "" , returncode = 0 )
157+ return MagicMock (stdout = b "abc123\n " , stderr = b "" , returncode = 0 )
158+ return MagicMock (stdout = b "" , stderr = b "" , returncode = 0 )
159159
160160 with patch ("subprocess.run" , side_effect = mock_run_side_effect ):
161161 with patch ("os.path.exists" , return_value = True ):
@@ -172,12 +172,12 @@ def mock_run_side_effect(*args, **kwargs):
172172def test_get_staged_files_with_complex_renames (git_operations ):
173173 """Test getting staged files with complex rename scenarios."""
174174 mock_output = (
175- "R old_name.py -> new_name.py\n "
176- "R old/path/file.py -> new/path/file.py\n "
177- "R100 renamed_completely.py -> totally_different.py\n "
175+ b "R old_name.py -> new_name.py\n "
176+ b "R old/path/file.py -> new/path/file.py\n "
177+ b "R100 renamed_completely.py -> totally_different.py\n "
178178 )
179179 with patch ("subprocess.run" ) as mock_run :
180- mock_run .return_value = MagicMock (stdout = mock_output , stderr = "" , returncode = 0 )
180+ mock_run .return_value = MagicMock (stdout = mock_output , stderr = b "" , returncode = 0 )
181181 files = git_operations .get_staged_files ()
182182
183183 assert len (files ) == 3
@@ -189,9 +189,9 @@ def test_get_staged_files_with_complex_renames(git_operations):
189189
190190def test_get_staged_files_with_submodules (git_operations ):
191191 """Test getting staged files with submodule changes."""
192- mock_output = "M regular_file.py\n M submodule\n " # Submodule change
192+ mock_output = b "M regular_file.py\n M submodule\n " # Submodule change
193193 with patch ("subprocess.run" ) as mock_run :
194- mock_run .return_value = MagicMock (stdout = mock_output , stderr = "" , returncode = 0 )
194+ mock_run .return_value = MagicMock (stdout = mock_output , stderr = b "" , returncode = 0 )
195195 files = git_operations .get_staged_files ()
196196
197197 assert len (files ) == 2
@@ -201,9 +201,9 @@ def test_get_staged_files_with_submodules(git_operations):
201201
202202def test_get_staged_files_with_permission_changes (git_operations ):
203203 """Test getting staged files with permission changes."""
204- mock_output = "M file_with_chmod.sh\n "
204+ mock_output = b "M file_with_chmod.sh\n "
205205 with patch ("subprocess.run" ) as mock_run :
206- mock_run .return_value = MagicMock (stdout = mock_output , stderr = "" , returncode = 0 )
206+ mock_run .return_value = MagicMock (stdout = mock_output , stderr = b "" , returncode = 0 )
207207 files = git_operations .get_staged_files ()
208208
209209 assert len (files ) == 1
0 commit comments