Python selenium how to transfer driver in unittest in two case of the same page

Test a login and logout. I already instantiated a webdriver, when I logged in. I want to reference this driver. in the logout case. How can I refer to this driver?

Why should I refer to the driver, in the login case instead of instantiating another driver? in the logout case If I instantiate a driver, again when I log out, then I open another browser and the test appears discontinuous given a url,;

the code is as follows


class TestLogin(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.get("https://www.some.com/aa/login.jsp")

    def test_login(self):
        username = "xxx"
        password = "yyy!"

        login_page = Login()
        login_page.user_login(self.driver, username, password)

        self.check_login()

    def check_login(self):
        current_url = self.driver.current_url
        expected_url = "/aa/main/index.do"
        self.assertIn(expected_url, current_url, msg="")

    def tearDown(self):
        self.driver.quit()
        

class TestLogout(unittest.TestCase):
    -sharp casecase
    def setUp(self, driver):
        self.driver = driver

    def test_logout(self):
        logout_button = self.driver.find_element_by_xpath("//a[@onclick="exitLogin();"]")
        logout_button.click()

        logout_confirm = self.driver.find_element_by_css_selector(".exitLogin .btn-primary")
        logout_confirm.click()

        self.check_logout()

    def check_logout(self):
        current_url = self.driver.current_url
        expected_url = "aa/login.jsp"
        self.assertIn(expected_url, current_url, msg="")

    def tearDown(self):
        self.driver.quit()


if __name__ == "__main__":
    suite = unittest.TestSuite()
    suite.addTest(TestLogin("test_login"))
    suite.addTest(TestLogout("test_logout"))

    runner = unittest.TextTestRunner()
    runner.run(suite)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea1ec9-4f065.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea1ec9-4f065.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?