Modified teardown method to handle login and logout failure.

In TestCase and AdminTestCase
	* Added condition to check login status inside teardown method.
	* Added try and finally, in case logout fails.
In BaseTestCase->teardown:
	* replaced driver.close() with driver.quit()

Partially implements blueprint: selenium-integration-testing
Closes-Bug: #1405553

Change-Id: Id1b520ec0a747ace89864bf7cc6b5d9b670fdc60
This commit is contained in:
mavinagi 2015-01-08 15:13:32 -06:00
parent 2af1512912
commit cc373e3244
1 changed files with 12 additions and 6 deletions

View File

@ -42,7 +42,7 @@ class BaseTestCase(testtools.TestCase):
def tearDown(self):
if os.environ.get('INTEGRATION_TESTS', False):
self.driver.close()
self.driver.quit()
if hasattr(self, 'vdisplay'):
self.vdisplay.stop()
super(BaseTestCase, self).tearDown()
@ -62,9 +62,12 @@ class TestCase(BaseTestCase):
self.home_pg = self.login_pg.login()
def tearDown(self):
self.home_pg.go_to_home_page()
self.home_pg.log_out()
super(TestCase, self).tearDown()
try:
if self.home_pg.is_logged_in:
self.home_pg.go_to_home_page()
self.home_pg.log_out()
finally:
super(TestCase, self).tearDown()
class AdminTestCase(BaseTestCase):
@ -77,5 +80,8 @@ class AdminTestCase(BaseTestCase):
password=self.conf.identity.admin_password)
def tearDown(self):
self.home_pg.log_out()
super(AdminTestCase, self).tearDown()
try:
if self.home_pg.is_logged_in:
self.home_pg.log_out()
finally:
super(AdminTestCase, self).tearDown()