From 5b4547af9a1324c56da3688e8fc2e2378a7ea127 Mon Sep 17 00:00:00 2001 From: JasonHomeWorkstationUbuntu Date: Mon, 9 Nov 2020 15:52:11 +1100 Subject: [PATCH] 6.1 Ensuring Test Isolation in Functional Tests --- src/functional_tests/__init__.py | 0 .../tests.py} | 12 +++++------- 2 files changed, 5 insertions(+), 7 deletions(-) create mode 100644 src/functional_tests/__init__.py rename src/{functional_tests.py => functional_tests/tests.py} (92%) diff --git a/src/functional_tests/__init__.py b/src/functional_tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/functional_tests.py b/src/functional_tests/tests.py similarity index 92% rename from src/functional_tests.py rename to src/functional_tests/tests.py index f396781..bf5bfe3 100644 --- a/src/functional_tests.py +++ b/src/functional_tests/tests.py @@ -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) @@ -60,8 +62,4 @@ 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') - + # Satisfied, she goes back to sleep \ No newline at end of file