6.1 Ensuring Test Isolation in Functional Tests

chap7
Jason Zhu 2020-11-09 15:52:11 +11:00
parent 05b8f21943
commit 5b4547af9a
2 changed files with 5 additions and 7 deletions

View File

View File

@ -1,9 +1,11 @@
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import unittest
class NewVisitorTest(unittest.TestCase):
class NewVisitorTest(LiveServerTestCase):
def setUp(self):
self.browser = webdriver.Firefox()
@ -19,7 +21,7 @@ class NewVisitorTest(unittest.TestCase):
def test_can_start_a_list_and_retrieve_it_later(self):
# Edith has heard about a cool new online to-do app. She goes
# to check out its homepage
self.browser.get('http://localhost:8000')
self.browser.get(self.live_server_url)
# She notices the page title and header mention to-do lists
self.assertIn('To-Do', self.browser.title)
@ -61,7 +63,3 @@ class NewVisitorTest(unittest.TestCase):
# She visits that URL - her to-do list is still there.
# Satisfied, she goes back to sleep
if __name__ == '__main__':
unittest.main(warnings='ignore')