@@ -4403,12 +4403,16 @@ def test_checkout_to_branch_with_untracked_files(self) -> None:
44034403 f .write ("new message\n " )
44044404
44054405 status = list (porcelain .status (self .repo ))
4406- self .assertEqual ([{"add" : [], "delete" : [], "modify" : []}, [], ["neu" ]], status )
4406+ self .assertEqual (
4407+ [{"add" : [], "delete" : [], "modify" : []}, [], [os .fsencode ("neu" )]], status
4408+ )
44074409
44084410 porcelain .checkout (self .repo , b"uni" )
44094411
44104412 status = list (porcelain .status (self .repo ))
4411- self .assertEqual ([{"add" : [], "delete" : [], "modify" : []}, [], ["neu" ]], status )
4413+ self .assertEqual (
4414+ [{"add" : [], "delete" : [], "modify" : []}, [], [os .fsencode ("neu" )]], status
4415+ )
44124416
44134417 def test_checkout_to_branch_with_new_files (self ) -> None :
44144418 porcelain .checkout (self .repo , b"uni" )
@@ -6099,8 +6103,8 @@ def test_status_base(self) -> None:
60996103
61006104 results = porcelain .status (self .repo )
61016105
6102- self .assertEqual (results .staged ["add" ][0 ], filename_add . encode ( "ascii" ))
6103- self .assertEqual (results .unstaged , [b "foo" ])
6106+ self .assertEqual (results .staged ["add" ][0 ], os . fsencode ( filename_add ))
6107+ self .assertEqual (results .unstaged , [os . fsencode ( "foo" ) ])
61046108
61056109 def test_status_with_core_preloadindex (self ) -> None :
61066110 """Test status with core.preloadIndex enabled."""
@@ -6139,7 +6143,7 @@ def test_status_with_core_preloadindex(self) -> None:
61396143
61406144 # Check that we detected the correct unstaged changes
61416145 unstaged_sorted = sorted (results .unstaged )
6142- expected_sorted = sorted ([f . encode ( "ascii" ) for f in modified_files ])
6146+ expected_sorted = sorted ([os . fsencode ( f ) for f in modified_files ])
61436147 self .assertEqual (unstaged_sorted , expected_sorted )
61446148
61456149 def test_status_all (self ) -> None :
@@ -6175,10 +6179,14 @@ def test_status_all(self) -> None:
61756179 f .write ("origstuff" )
61766180 results = porcelain .status (self .repo .path )
61776181 self .assertDictEqual (
6178- {"add" : [b"baz" ], "delete" : [b"foo" ], "modify" : [b"bar" ]},
6182+ {
6183+ "add" : [os .fsencode ("baz" )],
6184+ "delete" : [os .fsencode ("foo" )],
6185+ "modify" : [os .fsencode ("bar" )],
6186+ },
61796187 results .staged ,
61806188 )
6181- self .assertListEqual (results .unstaged , [b "blye" ])
6189+ self .assertListEqual (results .unstaged , [os . fsencode ( "blye" ) ])
61826190 results_no_untracked = porcelain .status (self .repo .path , untracked_files = "no" )
61836191 self .assertListEqual (results_no_untracked .untracked , [])
61846192
@@ -6194,7 +6202,9 @@ def test_status_untracked_path(self) -> None:
61946202 fh .write ("untracked" )
61956203
61966204 _ , _ , untracked = porcelain .status (self .repo .path , untracked_files = "all" )
6197- self .assertEqual (untracked , ["untracked_dir/untracked_file" ])
6205+ self .assertEqual (
6206+ untracked , [os .fsencode (os .path .join ("untracked_dir" , "untracked_file" ))]
6207+ )
61986208
61996209 def test_status_untracked_path_normal (self ) -> None :
62006210 # Create an untracked directory with multiple files
@@ -6216,16 +6226,16 @@ def test_status_untracked_path_normal(self) -> None:
62166226
62176227 # Test "normal" mode - should only show the directory, not individual files
62186228 _ , _ , untracked = porcelain .status (self .repo .path , untracked_files = "normal" )
6219- self .assertEqual (untracked , ["untracked_dir/" ])
6229+ self .assertEqual (untracked , [os . fsencode ( "untracked_dir" + os . sep ) ])
62206230
62216231 # Test "all" mode - should show all files
62226232 _ , _ , untracked_all = porcelain .status (self .repo .path , untracked_files = "all" )
62236233 self .assertEqual (
62246234 sorted (untracked_all ),
62256235 [
6226- "untracked_dir/ file1" ,
6227- "untracked_dir/ file2" ,
6228- "untracked_dir/ nested/ file3" ,
6236+ os . fsencode ( os . path . join ( "untracked_dir" , " file1")) ,
6237+ os . fsencode ( os . path . join ( "untracked_dir" , " file2")) ,
6238+ os . fsencode ( os . path . join ( "untracked_dir" , " nested" , " file3")) ,
62296239 ],
62306240 )
62316241
@@ -6253,11 +6263,15 @@ def test_status_mixed_tracked_untracked(self) -> None:
62536263
62546264 # In "normal" mode, should show individual untracked files in mixed dirs
62556265 _ , _ , untracked = porcelain .status (self .repo .path , untracked_files = "normal" )
6256- self .assertEqual (untracked , ["mixed_dir/untracked.txt" ])
6266+ self .assertEqual (
6267+ untracked , [os .fsencode (os .path .join ("mixed_dir" , "untracked.txt" ))]
6268+ )
62576269
62586270 # In "all" mode, should be the same for mixed directories
62596271 _ , _ , untracked_all = porcelain .status (self .repo .path , untracked_files = "all" )
6260- self .assertEqual (untracked_all , ["mixed_dir/untracked.txt" ])
6272+ self .assertEqual (
6273+ untracked_all , [os .fsencode (os .path .join ("mixed_dir" , "untracked.txt" ))]
6274+ )
62616275
62626276 def test_status_crlf_mismatch (self ) -> None :
62636277 # First make a commit as if the file has been added on a Linux system
@@ -6280,7 +6294,7 @@ def test_status_crlf_mismatch(self) -> None:
62806294
62816295 results = porcelain .status (self .repo )
62826296 self .assertDictEqual ({"add" : [], "delete" : [], "modify" : []}, results .staged )
6283- self .assertListEqual (results .unstaged , [b "crlf" ])
6297+ self .assertListEqual (results .unstaged , [os . fsencode ( "crlf" ) ])
62846298 self .assertListEqual (results .untracked , [])
62856299
62866300 def test_status_autocrlf_true (self ) -> None :
@@ -6348,7 +6362,8 @@ def test_status_autocrlf_input(self) -> None:
63486362
63496363 results = porcelain .status (self .repo )
63506364 self .assertDictEqual (
6351- {"add" : [b"crlf-new" ], "delete" : [], "modify" : []}, results .staged
6365+ {"add" : [os .fsencode ("crlf-new" )], "delete" : [], "modify" : []},
6366+ results .staged ,
63526367 )
63536368 # File committed with CRLF before autocrlf=input was enabled
63546369 # will NOT appear as unstaged because stat matching optimization
@@ -6382,7 +6397,7 @@ def test_status_autocrlf_input_modified(self) -> None:
63826397
63836398 results = porcelain .status (self .repo )
63846399 # Modified file should be detected as unstaged
6385- self .assertListEqual (results .unstaged , [b "crlf-file.txt" ])
6400+ self .assertListEqual (results .unstaged , [os . fsencode ( "crlf-file.txt" ) ])
63866401
63876402 def test_status_autocrlf_input_binary (self ) -> None :
63886403 """Test that binary files are not affected by autocrlf=input."""
@@ -6554,11 +6569,16 @@ def test_get_untracked_paths(self) -> None:
65546569 ),
65556570 )
65566571 self .assertEqual (
6557- {".gitignore" , "notignored" , "link" },
6572+ {os . fsencode ( ".gitignore" ), os . fsencode ( "notignored" ), os . fsencode ( "link" ) },
65586573 set (porcelain .status (self .repo ).untracked ),
65596574 )
65606575 self .assertEqual (
6561- {".gitignore" , "notignored" , "ignored" , "link" },
6576+ {
6577+ os .fsencode (".gitignore" ),
6578+ os .fsencode ("notignored" ),
6579+ os .fsencode ("ignored" ),
6580+ os .fsencode ("link" ),
6581+ },
65626582 set (porcelain .status (self .repo , ignored = True ).untracked ),
65636583 )
65646584
@@ -6679,14 +6699,16 @@ def test_get_untracked_paths_nested_gitignore(self) -> None:
66796699
66806700 # Test status() which uses exclude_ignored=True by default
66816701 status = porcelain .status (self .repo )
6682- self .assertEqual (["untracked.txt" ], status .untracked )
6702+ self .assertEqual ([os . fsencode ( "untracked.txt" ) ], status .untracked )
66836703
66846704 # Test status() with ignored=True which uses exclude_ignored=False
66856705 status_with_ignored = porcelain .status (self .repo , ignored = True )
66866706 # Should include cache directories
6687- self .assertIn ("untracked.txt" , status_with_ignored .untracked )
6707+ self .assertIn (os . fsencode ( "untracked.txt" ) , status_with_ignored .untracked )
66886708 for cache_dir in cache_dirs :
6689- self .assertIn (cache_dir + "/" , status_with_ignored .untracked )
6709+ self .assertIn (
6710+ os .fsencode (cache_dir + os .sep ), status_with_ignored .untracked
6711+ )
66906712
66916713 def test_get_untracked_paths_mixed_directory (self ) -> None :
66926714 """Test directory with both ignored and non-ignored files."""
@@ -6932,7 +6954,7 @@ def test_get_untracked_paths_normal(self) -> None:
69326954 _ , _ , untracked = porcelain .status (
69336955 repo = self .repo .path , untracked_files = "normal"
69346956 )
6935- self .assertEqual (untracked , ["untracked_dir/" ])
6957+ self .assertEqual (untracked , [os . fsencode ( "untracked_dir" + os . sep ) ])
69366958
69376959 def test_get_untracked_paths_top_level_issue_1247 (self ) -> None :
69386960 """Test for issue #1247: ensure top-level untracked files are detected."""
@@ -6955,7 +6977,7 @@ def test_get_untracked_paths_top_level_issue_1247(self) -> None:
69556977 # Test via status
69566978 status = porcelain .status (self .repo )
69576979 self .assertIn (
6958- "sample.txt" ,
6980+ os . fsencode ( "sample.txt" ) ,
69596981 status .untracked ,
69606982 "Top-level file 'sample.txt' should be in status.untracked" ,
69616983 )
0 commit comments