diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py
index 6c8813e062..cf14fe93df 100644
--- a/Lib/test/test_largefile.py
+++ b/Lib/test/test_largefile.py
@@ -49,6 +49,8 @@ class LargeFileTest:
unlink(TESTFN2)
+@unittest.skipIf(shutil.disk_usage(os.getcwd()).free < size * 1.5,
+ "not enough free disk space")
class TestFileMethods(LargeFileTest):
"""Test that each file function works as expected for large
(i.e. > 2 GiB) files.
@@ -150,6 +152,8 @@ class TestFileMethods(LargeFileTest):
self.assertTrue(f.seekable())
+@unittest.skipIf(shutil.disk_usage(os.getcwd()).free < size * 1.5 * 2,
+ "not enough free disk space")
class TestCopyfile(LargeFileTest, unittest.TestCase):
open = staticmethod(io.open)
@@ -166,6 +170,8 @@ class TestCopyfile(LargeFileTest, unittest.TestCase):
@unittest.skipIf(not hasattr(os, 'sendfile'), 'sendfile not supported')
+@unittest.skipIf(shutil.disk_usage(os.getcwd()).free < size * 1.5 * 2,
+ "not enough free disk space")
class TestSocketSendfile(LargeFileTest, unittest.TestCase):
open = staticmethod(io.open)
timeout = 3
@@ -251,10 +257,14 @@ def setUpModule():
unlink(TESTFN)
+@unittest.skipIf(shutil.disk_usage(os.getcwd()).free < size * 1.5,
+ "not enough free disk space")
class CLargeFileTest(TestFileMethods, unittest.TestCase):
open = staticmethod(io.open)
+@unittest.skipIf(shutil.disk_usage(os.getcwd()).free < size * 1.5,
+ "not enough free disk space")
class PyLargeFileTest(TestFileMethods, unittest.TestCase):
open = staticmethod(pyio.open)