Commit 925c5cb
authored
Revive and enhance
* test: Unskip `test_c_char` in `test_outparam` as it now passes.
The `test_c_char` in `test_outparam.py` was previously skipped due to
"failing for mysterious reasons". It now passes without modifications.
This suggests that underlying issues might have been resolved by this
package's community or within CPython over the past few years.
* test: Remove redundant `str` conversion from `comstring` in `test_outparam`.
Removed the `text_type = str` assignment and its usage in `comstring` function.
This change eliminates a redundant `str` conversion that remained from Python
2/3 version bridging.
* refactor: Use `logging` module for debug output in `test_outparam`.
Replaced `print` statements with `logger.debug` in `test_outparam.py` to allow
for more granular control and suppression of debug messages.
* test: Replace `ValueError` with `assert` for memory allocation check in `test_outparam`.
Changed the memory allocation check in `test_outparam.py` from raising a
`ValueError` to using an `assert` statement. In test code, avoiding `if`
branches is preferred.
* test: Verify `c_wchar_p` constructor does not allocate memory via COM allocator.
Added an assertion to `test_outparam.py` to verify that `c_wchar_p`'s
constructor does not allocate memory using `CoTaskMemAlloc`. This ensures
the memory is not identified as COM-allocated.
This check is vital to prevent the patched `__ctypes_from_outparam__` from
attempting to free unmanaged memory, which it expects to be COM-allocated.
* test: Remove irrelevant `BSTR` comment from `test_outparam`.
Removed a commented-out `BSTR` instantiation from `test_outparam.py`.
While its presence might have been intended to prevent some type definition
regression, it felt largely unrelated to the core purpose of this specific
test and was therefore removed for clarity.
* test: Refactor `test_c_char` to use `subTest` and verify memory deallocation.
Refactored `test_c_char` in `test_outparam.py` to utilize `self.subTest` for
improved test granularity. The test now explicitly verifies memory allocation
status using `malloc.DidAlloc` before and after calling
`__ctypes_from_outparam__`, ensuring correct memory deallocation behavior.
Old commented-out debug statements were also removed.
* docs: Remove outdated TODO comment from `test_outparam`.
Removed the `TODO` comment in `comtypes/test/test_outparam.py` regarding
"untested changes" and "global effects on other tests". This comment is
no longer relevant due to recent improvements and the unskipping of
`test_c_char`.
* fix: Rename `from_outparm` to `from_outparam` in `test_outparam.py`.
Corrected a typo in the function name `from_outparm` to `from_outparam`
within `test_outparam.py`.test_outparam. (#897)1 parent 5932fe9 commit 925c5cb
1 file changed
+30
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
63 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
69 | | - | |
70 | 74 | | |
71 | 75 | | |
72 | | - | |
| 76 | + | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 83 | + | |
82 | 84 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
100 | 109 | | |
101 | 110 | | |
102 | 111 | | |
| |||
0 commit comments