@@ -1558,6 +1558,52 @@ def test_CTRL_BREAK_EVENT(self):
1558
1558
self ._kill_with_event (signal .CTRL_BREAK_EVENT , "CTRL_BREAK_EVENT" )
1559
1559
1560
1560
1561
+ @unittest .skipUnless (sys .platform == "win32" , "Win32 specific tests" )
1562
+ class Win32ListdirTests (unittest .TestCase ):
1563
+ """Test listdir on Windows."""
1564
+
1565
+ def setUp (self ):
1566
+ self .created_paths = []
1567
+ for i in range (2 ):
1568
+ dir_name = 'SUB%d' % i
1569
+ dir_path = os .path .join (support .TESTFN , dir_name )
1570
+ file_name = 'FILE%d' % i
1571
+ file_path = os .path .join (support .TESTFN , file_name )
1572
+ os .makedirs (dir_path )
1573
+ with open (file_path , 'w' ) as f :
1574
+ f .write ("I'm %s and proud of it. Blame test_os.\n " % file_path )
1575
+ self .created_paths .extend ([dir_name , file_name ])
1576
+ self .created_paths .sort ()
1577
+
1578
+ def tearDown (self ):
1579
+ shutil .rmtree (support .TESTFN )
1580
+
1581
+ def test_listdir_no_extended_path (self ):
1582
+ """Test when the path is not an "extended" path."""
1583
+ # unicode
1584
+ self .assertEqual (
1585
+ sorted (os .listdir (support .TESTFN )),
1586
+ self .created_paths )
1587
+ # bytes
1588
+ self .assertEqual (
1589
+ sorted (os .listdir (os .fsencode (support .TESTFN ))),
1590
+ [os .fsencode (path ) for path in self .created_paths ])
1591
+
1592
+ def test_listdir_extended_path (self ):
1593
+ """Test when the path starts with '\\ \\ ?\\ '."""
1594
+ # See: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
1595
+ # unicode
1596
+ path = '\\ \\ ?\\ ' + os .path .abspath (support .TESTFN )
1597
+ self .assertEqual (
1598
+ sorted (os .listdir (path )),
1599
+ self .created_paths )
1600
+ # bytes
1601
+ path = b'\\ \\ ?\\ ' + os .fsencode (os .path .abspath (support .TESTFN ))
1602
+ self .assertEqual (
1603
+ sorted (os .listdir (path )),
1604
+ [os .fsencode (path ) for path in self .created_paths ])
1605
+
1606
+
1561
1607
@unittest .skipUnless (sys .platform == "win32" , "Win32 specific tests" )
1562
1608
@support .skip_unless_symlink
1563
1609
class Win32SymlinkTests (unittest .TestCase ):
@@ -2427,6 +2473,7 @@ def test_main():
2427
2473
PosixUidGidTests ,
2428
2474
Pep383Tests ,
2429
2475
Win32KillTests ,
2476
+ Win32ListdirTests ,
2430
2477
Win32SymlinkTests ,
2431
2478
NonLocalSymlinkTests ,
2432
2479
FSEncodingTests ,
0 commit comments