Skip to content

Commit

Permalink
issue pywinauto#873: fix win32 mocks for sphinx docs generation
Browse files Browse the repository at this point in the history
  • Loading branch information
airelil committed Jan 14, 2020
1 parent 127322e commit 896169d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions docs/code/pywinauto.remote_memory_block.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pywinauto.remote_memory_block
-----------------------------
.. automodule:: pywinauto.remote_memory_block
pywinauto.windows.remote_memory_block
-------------------------------------
.. automodule:: pywinauto.windows.remote_memory_block
:members:
:undoc-members:

6 changes: 3 additions & 3 deletions docs/code/pywinauto.uia_defines.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pywinauto.uia_defines
---------------------
.. automodule:: pywinauto.uia_defines
pywinauto.windows.uia_defines
-----------------------------
.. automodule:: pywinauto.windows.uia_defines
:members:
:undoc-members:

6 changes: 3 additions & 3 deletions docs/code/pywinauto.uia_element_info.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pywinauto.uia_element_info
--------------------------
.. automodule:: pywinauto.uia_element_info
pywinauto.windows.uia_element_info
----------------------------------
.. automodule:: pywinauto.windows.uia_element_info
:members:
:undoc-members:

6 changes: 3 additions & 3 deletions docs/code/pywinauto.win32_element_info.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pywinauto.win32_element_info
-----------------------------
.. automodule:: pywinauto.win32_element_info
pywinauto.windows.win32_element_info
------------------------------------
.. automodule:: pywinauto.windows.win32_element_info
:members:
:undoc-members:

6 changes: 3 additions & 3 deletions docs/code/pywinauto.win32_hooks.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pywinauto.win32_hooks
---------------------
.. automodule:: pywinauto.win32_hooks
pywinauto.windows.win32_hooks
-----------------------------
.. automodule:: pywinauto.windows.win32_hooks
:members:
:exclude-members: ID_TO_KEY, MOUSE_ID_TO_EVENT_TYPE, MOUSE_ID_TO_KEY, event_types
:undoc-members:
Expand Down
17 changes: 9 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@
'multiprocessing',
'_winreg',
'ctypes.wintypes',
'win32gui_struct',
'ctypes',
'ctypes.WINFUNCTYPE',
'ctypes.WinError',
'Xlib',
'Xlib.display',
'Xlib.ext.xtest',
'Xlib.ext',
'Xlib.XK',
'pywintypes',
'pywinauto.win32structures',
'pywinauto.win32defines',
"pywinauto.win32functions",
'pywinauto.windows.win32structures',
'pywinauto.windows.win32defines',
"pywinauto.windows.win32functions",
'pywinauto.windows.win32_hooks',
"win32functions",
'win32structures',
'comtypes',
Expand Down Expand Up @@ -83,14 +84,14 @@

default_import_func = builtin_module.__import__
def mocked_import(name, globals={}, locals={}, fromlist=[], level=0):
#print name
#print fromlist
#print(name)
#print(fromlist)
modules_to_mock = ['win32structures', 'win32functions', 'win32defines']
is_fromlist_listlike = isinstance(fromlist, list) or isinstance(fromlist, tuple)
if name in modules_to_mock or (is_fromlist_listlike and [x for x in fromlist if x in modules_to_mock]):
return mock.MagicMock()
else:
#print 'doing import for' + str(name) + str(fromlist)
#print 'doing import for: ' + str(name) + ", lst: " + str(fromlist)
return default_import_func(name, globals, locals, fromlist, level)
builtin_module.__import__ = mocked_import

Expand Down
1 change: 1 addition & 0 deletions docs/remote_execution.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ First option is PsExec. Thanks to `this post on StackExchange`_.

1. Download `PsTools`_.
2. Get process ID of RDP session using ``tasklist`` command. PowerShell script:

::

$session = tasklist /fo CSV | findstr RDP ; $session = $session.Split(",")[3] ; $session.Split('"')[1]
Expand Down
3 changes: 1 addition & 2 deletions pywinauto/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sys

from .base_application import WindowSpecification # noqa: W0611
Expand All @@ -38,4 +37,4 @@
else:
from .linux.application import Application # noqa: W0611

__all__ = [WindowSpecification, Application]
__all__ = ["WindowSpecification", "Application"]

0 comments on commit 896169d

Please sign in to comment.