Issue35458
Created on 2018-12-11 10:37 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11111 | merged | vstinner, 2018-12-11 10:41 | |
| Messages (4) | |||
|---|---|---|---|
| msg331601 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-12-11 10:37 | |
Extract of the test:
usage = shutil.disk_usage(os.path.dirname(__file__))
self.assertEqual(usage, shutil.disk_usage(__file__))
The test fails if another process creates or removes data on the disk partition. IMHO "self.assertEqual(usage, shutil.disk_usage(__file__))" must be removed, it cannot be reliable without mocking os.statvfs() / nt._getdiskusage().
Even if tests are run sequentially, the test can fail if a program creates a file between the two lines of code, the test cannot be reliable.
https://buildbot.python.org/all/#/builders/85/builds/1882
FAIL: test_disk_usage (test.test_shutil.TestShutil)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64le/build/Lib/test/test_shutil.py", line 1366, in test_disk_usage
self.assertEqual(usage, shutil.disk_usage(__file__))
AssertionError: usage(total=1925696024576, used=1793793806336, free=131902218240) != usage(total=1925696024576, used=1793793818624, free=131902205952)
|
|||
| msg331602 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-12-11 10:43 | |
The new test has been added by PR 9372: commit c8c0249c9e8f61ab7670119a5a5278354df27bbb Author: Joe Pamer <jopamer@users.noreply.github.com> Date: Tue Sep 25 10:57:36 2018 -0400 bpo-32557: allow shutil.disk_usage to take a file path on Windows also (GH-9372) |
|||
| msg331606 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-12-11 10:57 | |
Only the master branch is impacted (see bpo-32557). |
|||
| msg331609 - (view) | Author: STINNER Victor (vstinner) * | Date: 2018-12-11 11:05 | |
New changeset dc525f4315cdbe84693396d3f7a65a00425743bb by Victor Stinner in branch 'master': bpo-35458: Fix test_shutil.test_disk_usage() (GH-11111) https://github.com/python/cpython/commit/dc525f4315cdbe84693396d3f7a65a00425743bb |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:09 | admin | set | github: 79639 |
| 2018-12-11 11:05:35 | vstinner | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2018-12-11 11:05:25 | vstinner | set | messages: + msg331609 |
| 2018-12-11 10:57:55 | vstinner | set | messages: + msg331606 |
| 2018-12-11 10:43:46 | vstinner | set | messages: + msg331602 |
| 2018-12-11 10:41:37 | vstinner | set | keywords:
+ patch stage: patch review pull_requests: + pull_request10340 |
| 2018-12-11 10:37:38 | vstinner | create | |