abalakh / airgun

Airgun moved to https://github.com/SatelliteQE/airgun
https://github.com/SatelliteQE/airgun
1 stars 2 forks source link

Force close the session if any exception raised during session opening #24

Open abalakh opened 6 years ago

abalakh commented 6 years ago

Due to context manager nature, __exit__() catches exceptions in CM body, but not in CM's __enter__() section. This means in case any exception happens in __enter__() (e.g. host is unreachable) - session won't be closed and browser will remain opened after test run. The easiest way to solve this is probably to use try: except: in __enter__() method which will call __exit__() in case of exception.