New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up ctypes.test, use unittest test discovery #66258
Comments
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. |
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. |
I plan to do so as part of bpo-10572, if approved (or if there's no
Fair point, I'll get a new patch up soon. |
Here's a new patch; have I missed anything else that ought to be in setUpModule? |
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. |
But this doesn't matter. The patch LGTM. |
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. |
Maybe this one is actually right... |
Please commit. |
New changeset fc99cf3615bb by Zachary Ware in branch '3.4': New changeset 748fb6d622e8 by Zachary Ware in branch 'default': |
Done. Thank you for the reviews, Serhiy (and my apologies about all the spam with bad patches earlier today). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: