File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,9 +151,24 @@ def test_seekable(self):
151151 self .assertTrue (f .seekable ())
152152
153153
154+ def skip_no_disk_space (path , required ):
155+ def decorator (fun ):
156+ def wrapper (* args , ** kwargs ):
157+ if shutil .disk_usage (os .path .realpath (path )).free < required :
158+ hsize = int (required / 1024 / 1024 )
159+ raise unittest .SkipTest (
160+ f"required { hsize } MiB of free disk space" )
161+ return fun (* args , ** kwargs )
162+ return wrapper
163+ return decorator
164+
165+
154166class TestCopyfile (LargeFileTest , unittest .TestCase ):
155167 open = staticmethod (io .open )
156168
169+ # Exact required disk space would be (size * 2), but let's give it a
170+ # bit more tolerance.
171+ @skip_no_disk_space (TESTFN , size * 2.5 )
157172 def test_it (self ):
158173 # Internally shutil.copyfile() can use "fast copy" methods like
159174 # os.sendfile().
@@ -200,6 +215,9 @@ def run(sock):
200215 self .thread .start ()
201216 event .set ()
202217
218+ # Exact required disk space would be (size * 2), but let's give it a
219+ # bit more tolerance.
220+ @skip_no_disk_space (TESTFN , size * 2.5 )
203221 def test_it (self ):
204222 port = find_unused_port ()
205223 with socket .create_server (("" , port )) as sock :
You can’t perform that action at this time.
0 commit comments