Skip to content

Commit

Permalink
Add the Release doctest.
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd committed Dec 28, 2024
1 parent 2b24220 commit 4c4dd78
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/source/com_interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ The ``IUnknown`` as a Python class
if ``Release`` is called at the aforementioned timing, it may
raise an ``OSError``.

.. sourcecode:: pycon
.. doctest::

>>> import contextlib
>>> import io
>>> from comtypes.client import CreateObject, GetModule
>>> GetModule('UIAutomationCore.dll') # doctest: +ELLIPSIS
<module 'comtypes.gen.UIAutomationClient' from ...>
Expand All @@ -103,7 +105,11 @@ The ``IUnknown`` as a Python class
<POINTER(IUIAutomation) ptr=... at ...>
>>> iuia.Release()
0
>>> del iuia # doctest: +ELLIPSIS
>>> stderr = io.StringIO()
>>> with contextlib.redirect_stderr(stderr):
... del iuia
...
>>> print(stderr.getvalue()[:-1]) # doctest: +ELLIPSIS
Exception ignored in: <function _compointer_base.__del__ at ...>
Traceback (most recent call last):
...
Expand Down

0 comments on commit 4c4dd78

Please sign in to comment.