Chap2.2 The Python Standard Library's unittest Module
parent
e48aa8a282
commit
76a8bf8aed
|
@ -1,13 +1,22 @@
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
|
import unittest
|
||||||
|
|
||||||
browser = webdriver.Firefox()
|
class NewVisitorTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.browser = webdriver.Firefox()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.browser.quit()
|
||||||
|
|
||||||
|
def test_can_start_a_list_and_retrieve_it_later(self):
|
||||||
# Edith has heard about a cool new online to-do app. She goes
|
# Edith has heard about a cool new online to-do app. She goes
|
||||||
# to check out its homepage
|
# to check out its homepage
|
||||||
browser.get('http://localhost:8000')
|
self.browser.get('http://localhost:8000')
|
||||||
|
|
||||||
# She notices the page title and header mention to-do lists
|
# She notices the page title and header mention to-do lists
|
||||||
assert 'To-Do' in browser.title
|
self.assertIn('To-Do', self.browser.title)
|
||||||
|
self.fail('Finish the test!')
|
||||||
|
|
||||||
# She is invited to enter a to-do item straight away
|
# She is invited to enter a to-do item straight away
|
||||||
|
|
||||||
|
@ -30,4 +39,6 @@ assert 'To-Do' in browser.title
|
||||||
|
|
||||||
# Satisfied, she goes back to sleep
|
# Satisfied, she goes back to sleep
|
||||||
|
|
||||||
browser.quit()
|
if __name__ == '__main__':
|
||||||
|
unittest.main(warnings='ignore')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue