Skip to content

Commit

Permalink
Added tests for parent-related methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalmat committed Feb 28, 2022
1 parent 604e001 commit 8443451
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Cross-Platform module to gather information on and control windows opened on screen.

This module is a fork from asweigart's PyGetWindow module (https://github.com/asweigart/PyGetWindow), which adds Linux and macOS experimental support to the MS Windows-only original module, in the hope others can use it, test it or contribute
This module is a Python 3 fork from [asweigart's PyGetWindow module](https://github.com/asweigart/PyGetWindow), which adds Linux and macOS experimental support to the MS Windows-only original module, in the hope others can use it, test it or contribute

My most sincere thanks and acknowledgement to macdeport (https://github.com/macdeport) and holychowders (https://github.com/holychowders) for their help and moral boost.
My most sincere thanks and acknowledgement to [macdeport](https://github.com/macdeport) and [holychowders](https://github.com/holychowders) for their help and moral boost.

## Window Features

Expand Down Expand Up @@ -87,27 +87,29 @@ To install this module on your system, you can use pip:

pip install pywinctl

Alternatively, you can download the wheel file (.whl) located in "dist" folder, and run this (don't forget to replace 'x.x.xx' with proper version number):
Alternatively, you can download the wheel file (.whl) available in the [Donwnload page](https://pypi.org/project/pywin32/#files) and the [dist folder](https://github.com/Kalmat/PyWinCtl/tree/master/dist), and run this (don't forget to replace 'x.x.xx' with proper version number):

pip install PyWinCtl-x.x.xx-py3-none-any.whl

You may want to add '--force-reinstall' option to be sure you are installing the right dependencies version.
You may want to add `--force-reinstall` option to be sure you are installing the right dependencies version.

Then, you can use it on your own projects just importing it:

import pywinctl

## SUPPORT

In case you have a problem, comments or suggestions, do not hesitate to [open issues](https://github.com/Kalmat/PyWinCtl/issues) on the [project homepage](https://github.com/Kalmat/PyWinCtl)

## USING THIS CODE

If you want to use this code or contribute, you can either:

* Create a fork of this repository, or
* Download the repository, uncompress, and open it on your IDE of choice (e.g. PyCharm)
* Create a fork of the [repository](https://github.com/Kalmat/PyWinCtl), or
* [Download the repository](https://github.com/Kalmat/PyWinCtl/archive/refs/heads/master.zip), uncompress, and open it on your IDE of choice (e.g. PyCharm)

Be sure you install all dependencies described on "docs/requirements.txt" by using pip

In case you have any issues, comments or suggestions, do not hesitate to open an issue, or contact me ([email protected])

## TEST

To test this module on your own system, cd to "tests" folder and run:
Expand Down
Binary file added dist/PyWinCtl-0.0.17-py3-none-any.whl
Binary file not shown.
2 changes: 1 addition & 1 deletion src/pywinctl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Xlib and ewmh on Linux


__version__ = "0.0.15"
__version__ = "0.0.17"

import sys, collections, pyrect

Expand Down
4 changes: 2 additions & 2 deletions src/pywinctl/_pywinctl_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def isChild(self, parent: str) -> bool:
''parent'' title/handle (role:title) of the window/app you want to check if the current window is child of
"""
currParent = self.getParent()
if ":" not in parent:
if SEP not in parent:
part = currParent.split(SEP)
if len(part) > 1:
currParent = part[1]
Expand Down Expand Up @@ -1502,7 +1502,7 @@ def sendBehind(self, sb: bool = True) -> bool:

def getParent(self):
"""Returns the handle of the window parent"""
return self._hWnd.hWnd.parentWindow()
return self._hWnd.parentWindow()

def getHandle(self):
"""Returns the handle of the window"""
Expand Down
15 changes: 0 additions & 15 deletions tests/test_pywinctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ def basic_win32(npw):
# Test parent methods
parent = npw.getParent()
assert npw.isChild(parent)
parentObj = pywinctl.Win32Window(parent)
assert parentObj.isParent(npw.getHandle())

# Test menu options
menu = npw.menu.getMenu()
Expand Down Expand Up @@ -380,8 +378,6 @@ def basic_linux(npw):
# Test parent methods
parent = npw.getParent()
assert npw.isChild(parent)
parentObj = pywinctl.LinuxWindow(parent)
assert parentObj.isParent(npw.getHandle())

# Test closing
npw.close()
Expand Down Expand Up @@ -538,17 +534,6 @@ def basic_macOS(npw):
# Test parent methods
parent = npw.getParent()
assert parent and npw.isChild(parent)
part = parent.split(pywinctl._pywinctl_macos.SEP)
parentName = None
if len(part) > 1:
parentName = part[1]
windows = []
if parentName:
windows = pywinctl.getWindowsWithTitle(parentName)
parentObj = None
if windows:
parentObj = windows[0]
assert parentObj and parentObj.isChild(npw.getHandle())

# Test menu options
menu = npw.menu.getMenu()
Expand Down

0 comments on commit 8443451

Please sign in to comment.