diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-12-11 11:05:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-11 11:05:21 (GMT) |
commit | dc525f4315cdbe84693396d3f7a65a00425743bb (patch) | |
tree | accd52f07dff8d0befb7d12df7e8c39ef41158de /Lib | |
parent | 8905fcc85a6fc3ac394bc89b0bbf40897e9497a6 (diff) | |
download | cpython-dc525f4315cdbe84693396d3f7a65a00425743bb.zip cpython-dc525f4315cdbe84693396d3f7a65a00425743bb.tar.gz cpython-dc525f4315cdbe84693396d3f7a65a00425743bb.tar.bz2 |
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).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_shutil.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 9db6aec..ec8fcc3 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1363,13 +1363,17 @@ class TestShutil(unittest.TestCase): "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): |