Skip to content

Commit

Permalink
[6.14.z] ui_session: return airgun session as a context manager (#15155)
Browse files Browse the repository at this point in the history
ui_session: return airgun session as a context manager (#15050)

In `Satellite.ui_session()` context manager method,
`airgun.session.Session()` is also a context manager
and needs to be returned using the `with-yield` contruct,
so the Session's `__enter__` and `__exit__` methods are executed.

This fixes the problem where `Session.__exit__()` method was not called
and thus screenshot was not taken and the browser window was not closed
at the end of the test.

Also the `except Exception: raise` part was removed as redundant.

(cherry picked from commit 2618e01)

Co-authored-by: Pavel Novotny <[email protected]>
  • Loading branch information
Satellite-QE and pnovotny authored May 29, 2024
1 parent 20dbf46 commit 0834618
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1871,17 +1871,15 @@ def get_caller():
return None

try:
ui_session = Session(
with Session(
session_name=testname or get_caller(),
user=user or settings.server.admin_username,
password=password or settings.server.admin_password,
url=url,
hostname=self.hostname,
login=login,
)
yield ui_session
except Exception:
raise
) as ui_session:
yield ui_session
finally:
if self.record_property is not None and settings.ui.record_video:
video_url = settings.ui.grid_url.replace(
Expand Down

0 comments on commit 0834618

Please sign in to comment.