Skip to content

Commit

Permalink
Always use default timeout for Application().connect(path='proc.exe').
Browse files Browse the repository at this point in the history
  • Loading branch information
vasily-v-ryabov committed Jul 3, 2017
1 parent 365e855 commit 01075fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions pywinauto/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ def print_control_identifiers(self, depth=None, filename=None):

# Create a list of this control and all its descendants
all_ctrls = [this_ctrl, ] + this_ctrl.descendants()

# Create a list of all visible text controls
txt_ctrls = [ctrl for ctrl in all_ctrls if ctrl.can_be_label and ctrl.is_visible() and ctrl.window_text()]

Expand Down Expand Up @@ -905,9 +906,12 @@ def connect(self, **kwargs):
are also can be used instead of **process**, **handle** or **path**
"""

timeout = None
if 'timeout' in kwargs:
timeout = Timings.app_connect_timeout
retry_interval = Timings.app_connect_retry
if 'timeout' in kwargs and kwargs['timeout'] is not None:
timeout = kwargs['timeout']
if 'retry_interval' in kwargs and kwargs['retry_interval'] is not None:
retry_interval = kwargs['retry_interval']

connected = False
if 'process' in kwargs:
Expand All @@ -927,11 +931,10 @@ def connect(self, **kwargs):
connected = True

elif 'path' in kwargs:
if timeout is None:
self.process = process_from_module(kwargs['path'])
else:
self.process = timings.wait_until_passes(
timeout, 0, process_from_module, ProcessNotFoundError, kwargs['path'])
self.process = timings.wait_until_passes(
timeout, retry_interval, process_from_module,
ProcessNotFoundError, kwargs['path'],
)
connected = True

elif kwargs:
Expand Down
4 changes: 2 additions & 2 deletions pywinauto/unittests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ def test_connect_raises(self):

# try to pass an invalid path
self.assertRaises(
ProcessNotFoundError,
Application().connect, **{'path': "no app here"})
TimeoutError,
Application().connect, **{'path': "no app here", 'timeout': 0.0})

def test_top_window(self):
"""Test that top_window_() works correctly"""
Expand Down

0 comments on commit 01075fa

Please sign in to comment.