-
-
Notifications
You must be signed in to change notification settings - Fork 104
Allow the definition of the _midlSAFEARRAY(HRESULT) type.
#670
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing.
We need to write test code as well.
The test will include assertions ensuring that the definition of _midlSAFEARRAY(HRESULT) does not cause an error, while calling _midlSAFEARRAY(HRESULT).create raises a TypeError.
There are multiple modules for testing safearray, so I am currently looking for the most appropriate place to add the test.
comtypes/safearray.py
Outdated
| # safearray pointer instance does not work. | ||
| # See also: https://github.com/enthought/comtypes/issues/668 | ||
| "Cannot create SAFEARRAY type VT_HRESULT." | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting issue.
- )
+ )
junkmd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that test/test_midl_safearray_create.py is the most suitable location to test this behavior.
You could add a test like the following:
comtypes/comtypes/test/test_midl_safearray_create.py
Lines 1 to 4 in fb15f91
| # coding: utf-8 | |
| from ctypes import c_int, pointer, POINTER | |
| import unittest |
# coding: utf-8
-from ctypes import c_int, pointer, POINTER
+from ctypes import c_int, pointer, HRESULT, POINTER
import unittestcomtypes/comtypes/test/test_midl_safearray_create.py
Lines 82 to 87 in fb15f91
| self.assertEqual(unpacked.answer, 42) | |
| self.assertEqual(unpacked.needs_clarification, True) | |
| def test_ctype(self): | |
| extra = None | |
| cdata = c_int(1) |
self.assertEqual(unpacked.answer, 42)
self.assertEqual(unpacked.needs_clarification, True)
+ def test_HRESULT(self):
+ hr = HRESULT(1)
+ sa_type = comtypes.safearray._midlSAFEARRAY(HRESULT)
+ with self.assertRaises(TypeError):
+ sa_type.create([hr], extra=None)
+ with self.assertRaises(TypeError):
+ sa_type.create([hr])
+
def test_ctype(self):
extra = None
cdata = c_int(1)_midlSAFEARRAY(HRESULT) type.
junkmd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
|
Thank you very much for your help! |
|
You're welcome. |
Pull request for changes described in #668