[Python-checkins] bpo-35458: Fix test_shutil.test_disk_usage() (GH-11111)
Victor Stinner
webhook-mailer at python.org
Tue Dec 11 06:05:26 EST 2018
https://github.com/python/cpython/commit/dc525f4315cdbe84693396d3f7a65a00425743bb
commit: dc525f4315cdbe84693396d3f7a65a00425743bb
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-12-11T12:05:21+01:00
summary:
bpo-35458: Fix test_shutil.test_disk_usage() (GH-11111)
The following test fails if a different process creates or removes
a file on the same disk partition between the two lines:
usage = shutil.disk_usage(os.path.dirname(__file__))
self.assertEqual(usage, shutil.disk_usage(__file__))
Only test that disk_usage() succeed on a filename, but don't check
the result. Add also tests on the fields type (must be int).
files:
M Lib/test/test_shutil.py
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 9db6aec19206..ec8fcc3eef01 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1363,13 +1363,17 @@ def _boo(filename, extract_dir, extra):
"disk_usage not available on this platform")
def test_disk_usage(self):
usage = shutil.disk_usage(os.path.dirname(__file__))
- self.assertEqual(usage, shutil.disk_usage(__file__))
+ for attr in ('total', 'used', 'free'):
+ self.assertIsInstance(getattr(usage, attr), int)
self.assertGreater(usage.total, 0)
self.assertGreater(usage.used, 0)
self.assertGreaterEqual(usage.free, 0)
self.assertGreaterEqual(usage.total, usage.used)
self.assertGreater(usage.total, usage.free)
+ # bpo-32557: Check that disk_usage() also accepts a filename
+ shutil.disk_usage(__file__)
+
@unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
@unittest.skipUnless(hasattr(os, 'chown'), 'requires os.chown')
def test_chown(self):
More information about the Python-checkins
mailing list