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: Add test cases for ctypes/winreg for issues found in IronPython
Type: behavior Stage: resolved
Components: ctypes, Windows Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: BreamoreBoy, brett.cannon, brian.curtin, dino.viehland, ezio.melotti, python-dev, terry.reedy, theller, zach.ware
Priority: normal Keywords: patch

Created on 2010-02-04 19:17 by dino.viehland, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch.diff dino.viehland, 2010-02-04 19:17 Patch against 2.x trunk
patch30.diff dino.viehland, 2010-02-04 19:17 Patch against 3.x trunk
patch30.diff dino.viehland, 2010-02-04 19:48 Updated 3.x patch using context manager for exception test
patch.diff dino.viehland, 2010-02-04 21:02 Updated 2.x patch with context manager
patch30.diff dino.viehland, 2010-02-04 21:02 Updated 3.x patch with assertTrue(... is True)
issue7855-3.2.diff ezio.melotti, 2012-11-18 21:42 hg import-able patch against 3.2 review
issue7855.diff ezio.melotti, 2013-05-01 12:23 Patch against 3.x. review
Messages (22)
msg98844 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2010-02-04 19:17
This adds new test cases for bugs reported by Thomas Heller against IronPython for ctypes and winreg:
   ctypes: the variant bool type isn't supported
   winreg: errno is not correctly set when QueryValue fails
msg98845 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-02-04 19:28
Rather than calling QueryValue and using fail(...) if it doesn't throw, assertRaises(...) would do the trick.
msg98846 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-02-04 19:32
Also assertEqual(..., True) can be replaced by assertTrue(...) (same for False and assertFalse).
msg98847 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2010-02-04 19:33
The problem with assertRaises is I need to actually check the errno on the exception and assertRaises doesn't let me do that.
msg98848 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-02-04 19:33
Hmm... assertTrue(...) is semantically different from assertEqual(True, ...).
msg98849 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-02-04 19:35
Dino - if you use assertRaises as a context manager the exception is kept as an attribute on the context. You can make assertions about the exception after the with block has executed.
msg98850 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2010-02-04 19:38
I'll switch to the context manager form in the 3.x branch - it looks like that's not available in the 2.x branch.
msg98851 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2010-02-04 19:49
Ezio: I'm going to stick w/ assertEqual here as Michael points out these are different.  In particular I want to make sure that you can assign any true value to the ctypes field but when you read it back you get True or False regardless of the value assigned.
msg98853 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-02-04 20:15
For your purpose indeed assertTrue() is not appropriate, however assertEqual(x, True) works for several different x, including 1.0 or 1.
Also assertRaises can be used as a context manager on 2.7 too.
msg98857 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2010-02-04 21:04
Ahh, so it is in 2.7, apparently I was in a 2.6 enlistment.  I've updated the 2.x patch to use the context manager as well.

I've also switched to using assertTrue(x is True) and assertTrue(x is False) so that it's not checking precisely for the bool value based upon Ezio's feedback.
msg99073 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-02-08 23:46
Does this need committing? Dino - do you have checkin rights?
msg99075 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2010-02-08 23:58
Brett Cannon was going to try and look at it and commit it.  If you think it looks good you can commit it :)

I do not yet have commit privledges simply because I need to gen my SSH key and send that off to Brett.  I'm also hoping to get a little hand holding on the 1st few check-ins.
msg99076 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-02-08 23:59
Well, probably better for you to get the commit bit and DIY then. :-)
msg99991 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2010-02-24 01:42
Now that Dino has commit privileges and I just gave him the coordinator role, he can do the commit himself. =) Went ahead and assigned this issue to him.

And Dino, it would be helpful if you changed your username on the tracker to match your username on python-dev under "Your Details".
msg111947 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-29 15:07
Gentle poke in ribs can this be committed por favor?
msg175925 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-18 21:42
I made the latest 3.x patch hg import-able and cleaned up a few nits (whitespace, naming conventions, and used assertIs).
I have 2 comments though:
  1) the winreg test is defined in Win64WinregTests.  Is it specific to x64 or should it go in BaseWinregTests instead?
  2) the test_wintypes should be skipped on platforms where it's not supported.  Currently if I try to run test_ctypes I get:
test test_ctypes crashed -- Traceback (most recent call last):
  File "/home/wolf/dev/py/3.2/Lib/test/regrtest.py", line 1116, in runtest_inner
    indirect_test()
  File "/home/wolf/dev/py/3.2/Lib/test/test_ctypes.py", line 11, in test_main
    skipped, testcases = ctypes.test.get_tests(ctypes.test, "test_*.py", verbosity=0)
  File "/home/wolf/dev/py/3.2/Lib/ctypes/test/__init__.py", line 64, in get_tests
    mod = __import__(modname, globals(), locals(), ['*'])
  File "/home/wolf/dev/py/3.2/Lib/ctypes/test/test_wintypes.py", line 3, in <module>
    from ctypes import wintypes
  File "/home/wolf/dev/py/3.2/Lib/ctypes/wintypes.py", line 20, in <module>
    class VARIANT_BOOL(ctypes._SimpleCData):
ValueError: _type_ 'v' not supported

I get this error on 2.7/3.2/3.3/3.4 when I try to import wintypes.
Maybe this should be an ImportError instead?
Unfortunately I'm on Linux, so I can test and commit the patch myself, but feel free to address my comments and commit it.
msg183320 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-03-02 13:13
Dino, what's the status of this?
msg188213 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-05-01 12:23
The attached patch now passes on Linux.  I raised a SkipTest on non-Windows platforms and changed Lib/ctypes/test/__init__.py to handle it.  If someone can confirm that the patch works on Windows I'll commit it.

The ValueError I reported in my previous message has also been reported in #16396 and should be fixed.
msg188231 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2013-05-01 16:01
The patch works fine on Win 7 for me.  I left a couple comments on Rietveld, neither of which is of great importance.
msg188365 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-04 14:48
New changeset 5f82b68c1f28 by Ezio Melotti in branch '3.3':
#7855: Add tests for ctypes/winreg for issues found in IronPython.  Initial patch by Dino Viehland.
http://hg.python.org/cpython/rev/5f82b68c1f28

New changeset df655ebf74d7 by Ezio Melotti in branch 'default':
#7855: merge with 3.3.
http://hg.python.org/cpython/rev/df655ebf74d7
msg188366 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-04 14:59
New changeset e71406d8ed5d by Ezio Melotti in branch '2.7':
#7855: Add tests for ctypes/winreg for issues found in IronPython.  Initial patch by Dino Viehland.
http://hg.python.org/cpython/rev/e71406d8ed5d
msg188367 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-05-04 15:00
This should be fixed now.
Thanks for the report and the patch (and thanks Zach for confirming that it works on Windows and for the review)!
History
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52103
2013-05-04 15:00:43ezio.melottisetstatus: open -> closed
messages: + msg188367

assignee: dino.viehland -> ezio.melotti
resolution: fixed
stage: patch review -> resolved
2013-05-04 14:59:14python-devsetmessages: + msg188366
2013-05-04 14:48:05python-devsetnosy: + python-dev
messages: + msg188365
2013-05-01 16:02:11michael.foordsetnosy: - michael.foord
2013-05-01 16:01:32zach.waresetmessages: + msg188231
2013-05-01 12:23:06ezio.melottisetfiles: + issue7855.diff
versions: - Python 3.2
nosy: + terry.reedy, zach.ware

messages: + msg188213
2013-03-02 13:13:31ezio.melottisetmessages: + msg183320
2012-11-18 21:42:19ezio.melottisetfiles: + issue7855-3.2.diff

messages: + msg175925
versions: + Python 3.3, Python 3.4, - Python 3.1
2010-07-29 15:07:48BreamoreBoysetnosy: + BreamoreBoy

messages: + msg111947
versions: + Python 3.1
2010-02-24 01:42:37brett.cannonsetassignee: theller -> dino.viehland

messages: + msg99991
nosy: + brett.cannon
2010-02-08 23:59:10michael.foordsetmessages: + msg99076
2010-02-08 23:58:00dino.viehlandsetmessages: + msg99075
2010-02-08 23:46:37michael.foordsetmessages: + msg99073
2010-02-04 21:04:21dino.viehlandsetmessages: + msg98857
2010-02-04 21:02:48dino.viehlandsetfiles: + patch30.diff
2010-02-04 21:02:27dino.viehlandsetfiles: + patch.diff
2010-02-04 20:15:08ezio.melottisetpriority: normal

messages: + msg98853
stage: patch review
2010-02-04 19:49:15dino.viehlandsetmessages: + msg98851
2010-02-04 19:48:14dino.viehlandsetfiles: + patch30.diff
2010-02-04 19:38:34dino.viehlandsetmessages: + msg98850
2010-02-04 19:35:04michael.foordsetmessages: + msg98849
2010-02-04 19:33:42michael.foordsetmessages: + msg98848
2010-02-04 19:33:34dino.viehlandsetmessages: + msg98847
2010-02-04 19:32:19ezio.melottisetpriority: normal -> (no value)

assignee: theller

keywords: - needs review
nosy: + ezio.melotti
messages: + msg98846
stage: patch review -> (no value)
2010-02-04 19:28:43brian.curtinsetpriority: normal

assignee: theller -> (no value)

keywords: + needs review
nosy: + brian.curtin, michael.foord
messages: + msg98845
stage: patch review
2010-02-04 19:17:58dino.viehlandsetfiles: + patch30.diff
type: behavior
versions: + Python 3.2
2010-02-04 19:17:09dino.viehlandcreate