This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix test discovery for test_largefile.py
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: brett.cannon, ezio.melotti, facundobatista, giampaolo.rodola, python-dev, serhiy.storchaka, zach.ware
Priority: normal Keywords: patch

Created on 2013-06-19 21:00 by zach.ware, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_largefile_discovery.diff zach.ware, 2013-06-19 21:00 test_largefile.py fix, version 1 review
test_largefile_discovery.v2-3.3.diff zach.ware, 2013-07-04 04:34 Version 2, with minor refactoring
test_largefile_discovery.v3-3.3.diff zach.ware, 2013-07-05 18:58 Version 3, faster on Windows
Messages (5)
msg191494 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2013-06-19 21:00
This one is another inheritance issue.  The patch removes unittest.TestCase as a base for LargeFileTest and converts test_main into setUpModule, load_tests, and tearDownModule.  This seems like the way to go due to the fact that the order of test execution matters: test_seek must be first and test_truncate must be last.  The only way around that restriction would be to create a new copy of the file for test_truncate, which would make the test take even longer and use even more resources.

Also, the programmatic creation of the C and Py variants of the test has been changed from creating an empty subclass of LargeFileTest which is then renamed and assigned an 'open' attr, to using the three-arg form of type to create a subclass of LargeFileTest and unittest.TestCase with name set and an 'open' attr pointing to the correct function.

Lastly, the superfluous check on whether f.truncate is available that had been in test_main is now removed so that the test is properly marked as skipped if skipped.
msg192033 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-06-29 11:51
There is other problem with test_largefile. It not allows running only selected tests. I.e.

./python -m test.regrtest -v -m test_lseek test_largefile

Looks as test_largefile was suboptimal converted to unittest.
msg192271 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2013-07-04 04:34
Here's a stab at fixing that issue.  It works, but I don't know that it's the best solution.

This patch converts test_seek into setUp, and attempts to make sure the test file is in the same state at the beginning of each test, with a new tearDownClass removing the file after each implementation has been tested.  setUp also tries not to recreate the file from scratch each time, as doing so would make the test take an unreasonably long time on Windows (currently the test takes around 5 minutes on my Windows 7 machine, creating the file twice.  I have not yet tested this patch on Windows, but should be able to before Saturday).

With this change, load_tests has been removed, and the Py/C test subclasses are created manually.

Since this has moved from strictly test discovery fixes to a bit more of a refactor, I made a few other minor changes as well.  I removed the verbose prints and wrapped a couple of long lines, changed the filesystem test (which is now in setUpModule) to remove its test file, and fixed a couple of comments. Also, I removed 'oldhandler' from the issue490453 fix (since it was unused and only served to confuse me until I did some research on it), though I suppose if preferred, it could be saved to reset the signal handler at the end of the run.  Either way, that whole fix was also moved into setUpModule with other setup code.

This patch is against 3.3; it does not apply cleanly to default due to a conflict between IOError and OSError in two places.  It should merge forward fine, though.
msg192346 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2013-07-05 18:58
After testing on Windows, here's version 3.  This version changes tearDownClass to truncate the file rather than unlink it, and adds a check to make sure the file is properly truncated to 0 length.  Unlinking the file makes the test take an extra 40 seconds on my machine, I suspect due to Windows trying to simultaneously deallocate one 2GB file and build another.  To go with that change, tearDownModule is added, which does unlink TESTFN.

Also changed in this version, I've removed the "use_resources = ['largefile',]" assignment I had added to the "if __name__ == '__main__'" stanza; I've since learned that it has no effect (support.requires lets anything pass if the test module's __name__ is 
"__main__").
msg193222 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-17 10:44
New changeset dd75dbed1135 by Serhiy Storchaka in branch '3.3':
Issue #18266: test_largefile now works with unittest test discovery and
http://hg.python.org/cpython/rev/dd75dbed1135

New changeset 2d8573e12591 by Serhiy Storchaka in branch 'default':
Issue #18266: test_largefile now works with unittest test discovery and
http://hg.python.org/cpython/rev/2d8573e12591
History
Date User Action Args
2022-04-11 14:57:47adminsetgithub: 62466
2013-07-17 11:39:33serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-07-17 10:44:40python-devsetnosy: + python-dev
messages: + msg193222
2013-07-17 09:56:44serhiy.storchakasetassignee: serhiy.storchaka
stage: patch review
2013-07-05 18:58:44zach.waresetfiles: + test_largefile_discovery.v3-3.3.diff

messages: + msg192346
2013-07-04 04:35:00zach.waresetfiles: + test_largefile_discovery.v2-3.3.diff

messages: + msg192271
2013-06-29 11:51:26serhiy.storchakasetnosy: + facundobatista, giampaolo.rodola
messages: + msg192033
2013-06-28 19:56:28serhiy.storchakasetnosy: + serhiy.storchaka
2013-06-19 21:00:54zach.warecreate