@@ -689,6 +689,8 @@ def __init__(
689689 self ._dyn_patcher : Optional [DynamicPatcher ] = None
690690 self ._patching = False
691691 self ._paused = False
692+ self .has_copy_file_range = False
693+ self .has_copy_file = False
692694
693695 def checkcache (self , filename = None ):
694696 """Calls the original linecache.checkcache making sure no fake OS calls
@@ -990,6 +992,14 @@ def setUp(self, doctester: Any = None) -> None:
990992 if self .has_fcopy_file :
991993 shutil ._HAS_FCOPYFILE = False # type: ignore[attr-defined]
992994
995+ self .has_copy_file_range = (
996+ sys .platform == "linux"
997+ and hasattr (shutil , "_USE_CP_COPY_FILE_RANGE" )
998+ and shutil ._USE_CP_COPY_FILE_RANGE
999+ )
1000+ if self .has_copy_file_range :
1001+ shutil ._USE_CP_COPY_FILE_RANGE = False # type: ignore[attr-defined]
1002+
9931003 # do not use the fd functions, as they may not be available in the target OS
9941004 if hasattr (shutil , "_use_fd_functions" ):
9951005 shutil ._use_fd_functions = False # type: ignore[module-attr]
@@ -1047,7 +1057,8 @@ def _set_glob_os_functions(self):
10471057 if sys .version_info >= (3 , 13 ):
10481058 globber = glob ._StringGlobber # type: ignore[module-attr]
10491059 globber .lstat = staticmethod (os .lstat )
1050- globber .scandir = staticmethod (os .scandir )
1060+ if sys .version_info < (3 , 14 ):
1061+ globber .scandir = staticmethod (os .scandir )
10511062
10521063 def patch_functions (self ) -> None :
10531064 assert self ._stubs is not None
@@ -1124,6 +1135,8 @@ def tearDown(self, doctester: Any = None):
11241135 self .stop_patching ()
11251136 if self .has_fcopy_file :
11261137 shutil ._HAS_FCOPYFILE = True # type: ignore[attr-defined]
1138+ if self .has_copy_file_range :
1139+ shutil ._USE_CP_COPY_FILE_RANGE = True # type: ignore[attr-defined]
11271140
11281141 reset_ids ()
11291142 if self .is_doc_test :
0 commit comments