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: Clean up ctypes.test, use unittest test discovery
Type: enhancement Stage: resolved
Components: ctypes, Tests Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zach.ware Nosy List: amaury.forgeotdarc, belopolsky, ezio.melotti, meador.inge, michael.foord, pitrou, python-dev, serhiy.storchaka, zach.ware
Priority: normal Keywords: patch

Created on 2014-07-24 20:32 by zach.ware, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ctypes.test-cleanup.diff zach.ware, 2014-07-24 20:32 review
issue22060.diff zach.ware, 2014-08-07 21:19 review
issue22060.v2.diff zach.ware, 2014-08-08 15:35 review
Messages (11)
msg223891 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-07-24 20:32
Attached is a patch that aims to clean up the ctypes tests a bit, namely by removing the custom resource management (which conflicts with regrtest), the custom test discovery (which is better left to unittest), and the custom test running (which is better covered by unittest and regrtest).  The one thing I'm not entirely confident about removing is the custom refleak testing, but it does not seem to work correctly in 3.x anyway (though in 2.7, the custom refleak hunter reports "leaks" that the regrtest refleak hunter does not).

There were only a few uses of the custom resource management, all of which were replaced or removed.  test_SEH in test_win32 used "requires('SEH')", but that test should now be sufficiently guarded with unittest skip decorators (only trying the test on Windows, with Python built in Release configuration by MSVC).  test_PyLong_Long in test_python_api used "requires('refcount')", but that should be covered by the @support.refcount_test decorator (added long after the 'requires' call).  Two instances of "is_resource_enabled('printing')" were replaced by "if test.support.verbose".

The same number of tests run (all successfully) on Windows, I have not yet tested on any other platforms.
msg224956 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-06 18:21
Changes look simple and straightforward. LGTM.

It would be good also move tests into the Lib/test/test_ctypes subdirectory and eliminate Lib/test/test_ctypes.py (may be in separate issue). And may be move initialization and verbose printinting in setUpModule() functions.
msg224960 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-08-06 18:59
> Serhiy Storchaka added the comment:
> It would be good also move tests into the Lib/test/test_ctypes subdirectory and eliminate Lib/test/test_ctypes.py (may be in separate issue).

I plan to do so as part of #10572, if approved (or if there's no
vehemently negative feedback on that issue within a couple weeks).

> And may be move initialization and verbose printinting in setUpModule() functions.

Fair point, I'll get a new patch up soon.
msg225041 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-08-07 21:19
Here's a new patch; have I missed anything else that ought to be in setUpModule?
msg225062 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-08 06:55
When the verbose variable is imported, it is impossible to control verbosity at runtime. It will be better to import only the test.support module itself and then access its attribute.
msg225064 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-08 08:19
But this doesn't matter. The patch LGTM.
msg225075 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-08-08 15:26
In pre-commit testing, I realized I was getting skips that I shouldn't have been getting, and it turns out that I screwed up both setUpModule functions from the previous patch.  New patch fixes test_loading and test_find to use the skipTest method instead of skip decorators, so the necessary variables are actually set when they're looked for.  I also combined the setUpModule in test_find with the setUp method of the TestOpenGL_libs into a setUpClass classmethod, which makes things a little simpler and cleaner.

Since I was in there anyway, I went ahead and fixed your point about test.support.verbose.  I had not thought about that issue previously.

I'll go ahead and commit later today unless something else jumps out as being wrong.
msg225076 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-08-08 15:35
Maybe this one is actually right...
msg225080 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-08 18:28
Please commit.
msg225081 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-08 18:35
New changeset fc99cf3615bb by Zachary Ware in branch '3.4':
Issue #22060: Clean up/simplify test_ctypes, use test discovery
http://hg.python.org/cpython/rev/fc99cf3615bb

New changeset 748fb6d622e8 by Zachary Ware in branch 'default':
Closes #22060: Merge with 3.4
http://hg.python.org/cpython/rev/748fb6d622e8
msg225082 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-08-08 18:37
Done.  Thank you for the reviews, Serhiy (and my apologies about all the spam with bad patches earlier today).
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66258
2014-08-08 18:37:28zach.waresetassignee: zach.ware
messages: + msg225082
2014-08-08 18:35:41python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg225081

resolution: fixed
stage: patch review -> resolved
2014-08-08 18:28:35serhiy.storchakasetmessages: + msg225080
2014-08-08 15:35:49zach.waresetfiles: - issue22060.v2.diff
2014-08-08 15:35:26zach.waresetfiles: + issue22060.v2.diff

messages: + msg225076
2014-08-08 15:29:53zach.waresetfiles: - issue22060.v2.diff
2014-08-08 15:29:44zach.waresetfiles: + issue22060.v2.diff
2014-08-08 15:26:23zach.waresetversions: + Python 3.4
2014-08-08 15:26:13zach.waresetfiles: + issue22060.v2.diff

messages: + msg225075
2014-08-08 08:19:19serhiy.storchakasetmessages: + msg225064
2014-08-08 06:55:14serhiy.storchakasetmessages: + msg225062
2014-08-07 21:19:23zach.waresetfiles: + issue22060.diff

messages: + msg225041
2014-08-06 18:59:05zach.waresetmessages: + msg224960
2014-08-06 18:21:01serhiy.storchakasetnosy: + pitrou, michael.foord
messages: + msg224956
2014-08-05 05:39:13ezio.melottisetnosy: + ezio.melotti
2014-07-24 20:32:05zach.warecreate