classification
Title: Refactor test_zipfile
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: alanmcintyre, ezio.melotti, python-dev, serhiy.storchaka, terry.reedy, zach.ware
Priority: normal Keywords: patch

Created on 2013-05-09 09:57 by serhiy.storchaka, last changed 2013-07-22 18:12 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
test_zipfile.patch serhiy.storchaka, 2013-05-09 09:57 review
test_zipfile_2.patch serhiy.storchaka, 2013-05-10 16:06 review
test_zipfile_3.patch serhiy.storchaka, 2013-06-17 11:57 review
Messages (10)
msg188760 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-09 09:57
Here is a patch which refactors test_zipfile, decreases it's size by 269 lines, makes adding tests for new compression types and new tests for all compression types simpler, and makes test_zipfile discoverable.
msg188874 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-05-10 20:21
As I understand this, the main refactoring is to put the tests duplicated for zlib, bz2, and lzma into a master class that is then subclasses=d for each of the compressors. This looks like a great idea.
msg188883 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-10 21:06
Yes, the first patch includes only this change (plus some needed regrouping and renaming). The second patch in additional wraps long lines, uses asserts with better error reporting, has better resource management ("with" operator and addCleanup), and contains other minor changes (see a difference between two patches).
msg191204 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-06-15 13:19
If there are no objection I'm going to commit this patch soon.
msg191323 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-06-17 11:57
Thank you Terry for review. Here is updated patch addressed Terry's comments. Now random datas for tests generated once per class (generating them once per module will be more cumbersome and will save less time). Arguments for zipfile.open() now generated from a special generator. This simplifies the code and makes possible to determine with what argument test is failed. I don't think subtest() is appropriate here (in any case it is 3.4 only).
msg191326 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-06-17 12:15
When applying first Terry's suggestion I found a bug. self.list_gen was a generator and when self.list_gen used second time it was exhausted. As result, some tests were skipped and a bug with concatenating bytes and '\n' was not exposed.

This bug should be fixed in 2.7 if it exists.
msg192886 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-07-11 19:08
If there are no objections I'm going to commit the patch soon.
msg192901 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2013-07-11 20:29
No complaints here.
msg193552 - (view) Author: Roundup Robot (python-dev) Date: 2013-07-22 18:04
New changeset bb63f813a00f by Serhiy Storchaka in branch '3.3':
Issue #17944: test_zipfile now discoverable and uses subclassing to
http://hg.python.org/cpython/rev/bb63f813a00f

New changeset 5812a3683402 by Serhiy Storchaka in branch 'default':
Issue #17944: test_zipfile now discoverable and uses subclassing to
http://hg.python.org/cpython/rev/5812a3683402
msg193555 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-07-22 18:12
> This bug should be fixed in 2.7 if it exists.

It doesn't exists in 2.7.
History
Date User Action Args
2013-07-22 18:12:03serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg193555

stage: patch review -> resolved
2013-07-22 18:04:23python-devsetnosy: + python-dev
messages: + msg193552
2013-07-11 20:29:21zach.waresetmessages: + msg192901
2013-07-11 19:08:32serhiy.storchakasetmessages: + msg192886
2013-06-17 12:15:45serhiy.storchakasetmessages: + msg191326
2013-06-17 11:57:19serhiy.storchakasetfiles: + test_zipfile_3.patch

messages: + msg191323
2013-06-15 13:19:40serhiy.storchakasetmessages: + msg191204
2013-06-09 19:19:16serhiy.storchakasetassignee: serhiy.storchaka
2013-05-10 21:06:23serhiy.storchakasetmessages: + msg188883
2013-05-10 20:21:42terry.reedysetnosy: + terry.reedy
messages: + msg188874
2013-05-10 16:06:16serhiy.storchakasetfiles: + test_zipfile_2.patch
2013-05-09 09:57:50serhiy.storchakacreate