File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change
1
+ import contextlib
1
2
import collections .abc
2
3
import io
3
4
import os
@@ -1716,21 +1717,18 @@ def test_glob_permissions(self):
1716
1717
# Patching is needed to avoid relying on the filesystem
1717
1718
# to return the order of the files as the error will not
1718
1719
# happen if the symlink is the last item.
1719
-
1720
- with mock .patch ("os.scandir" ) as scandir :
1721
- scandir .return_value = sorted (os .scandir (base ))
1720
+ real_scandir = os .scandir
1721
+ def my_scandir (path ):
1722
+ with real_scandir (path ) as scandir_it :
1723
+ entries = list (scandir_it )
1724
+ entries .sort (key = lambda entry : entry .name )
1725
+ return contextlib .nullcontext (entries )
1726
+
1727
+ with mock .patch ("os.scandir" , my_scandir ):
1722
1728
self .assertEqual (len (set (base .glob ("*" ))), 3 )
1723
-
1724
- subdir .mkdir ()
1725
-
1726
- with mock .patch ("os.scandir" ) as scandir :
1727
- scandir .return_value = sorted (os .scandir (base ))
1729
+ subdir .mkdir ()
1728
1730
self .assertEqual (len (set (base .glob ("*" ))), 4 )
1729
-
1730
- subdir .chmod (000 )
1731
-
1732
- with mock .patch ("os.scandir" ) as scandir :
1733
- scandir .return_value = sorted (os .scandir (base ))
1731
+ subdir .chmod (000 )
1734
1732
self .assertEqual (len (set (base .glob ("*" ))), 4 )
1735
1733
1736
1734
def _check_resolve (self , p , expected , strict = True ):
You can’t perform that action at this time.
0 commit comments