@@ -78,10 +78,10 @@ browser = webdriver.Firefox()
78
78
79
79
# Edith has heard about a cool new online to-do app. She goes
80
80
# to check out its homepage
81
- browser.get(' http://localhost:8000' )
81
+ browser.get(" http://localhost:8000" )
82
82
83
83
# She notices the page title and header mention to-do lists
84
- assert ' To-Do' in browser.title
84
+ assert " To-Do" in browser.title
85
85
86
86
# She is invited to enter a to-do item straight away
87
87
@@ -165,7 +165,7 @@ And then, in another shell, run the tests:
165
165
$ pass:quotes[*python functional_tests.py*]
166
166
Traceback (most recent call last):
167
167
File "...python-tdd-book/functional_tests.py", line 10, in <module>
168
- assert ' To-Do' in browser.title
168
+ assert " To-Do" in browser.title
169
169
AssertionError
170
170
----
171
171
@@ -193,7 +193,7 @@ something like:
193
193
[role="skipme"]
194
194
[source,python]
195
195
----
196
- assert ' To-Do' in browser.title, "Browser title was " + browser.title
196
+ assert " To-Do" in browser.title, "Browser title was " + browser.title
197
197
----
198
198
199
199
And we could also use a `try/finally` to clean up the old Firefox window. But
@@ -209,27 +209,28 @@ use that! In [keep-together]#_functional_tests.py_#:
209
209
from selenium import webdriver
210
210
import unittest
211
211
212
- class NewVisitorTest(unittest.TestCase): #<1>
213
212
214
- def setUp(self): #<3>
213
+ class NewVisitorTest(unittest.TestCase): # <1>
214
+ def setUp(self): # <3>
215
215
self.browser = webdriver.Firefox()
216
216
217
- def tearDown(self): #<3>
217
+ def tearDown(self): # <3>
218
218
self.browser.quit()
219
219
220
- def test_can_start_a_list_and_retrieve_it_later(self): #<2>
220
+ def test_can_start_a_list_and_retrieve_it_later(self): # <2>
221
221
# Edith has heard about a cool new online to-do app. She goes
222
222
# to check out its homepage
223
- self.browser.get(' http://localhost:8000' )
223
+ self.browser.get(" http://localhost:8000" )
224
224
225
225
# She notices the page title and header mention to-do lists
226
- self.assertIn(' To-Do' , self.browser.title) #<4>
227
- self.fail(' Finish the test!' ) #<5>
226
+ self.assertIn(" To-Do" , self.browser.title) # <4>
227
+ self.fail(" Finish the test!" ) # <5>
228
228
229
229
# She is invited to enter a to-do item straight away
230
230
[...rest of comments as before]
231
231
232
- if __name__ == '__main__': #<6>
232
+
233
+ if __name__ == "__main__": # <6>
233
234
unittest.main()
234
235
----
235
236
====
@@ -289,7 +290,7 @@ FAIL: test_can_start_a_list_and_retrieve_it_later
289
290
Traceback (most recent call last):
290
291
File "...python-tdd-book/functional_tests.py", line 18, in
291
292
test_can_start_a_list_and_retrieve_it_later
292
- self.assertIn(' To-Do' , self.browser.title)
293
+ self.assertIn(" To-Do" , self.browser.title)
293
294
AssertionError: 'To-Do' not found in 'The install worked successfully!
294
295
Congratulations!'
295
296
@@ -335,10 +336,10 @@ index d333591..b0f22dc 100644
335
336
+import unittest
336
337
337
338
-browser = webdriver.Firefox()
338
- -browser.get(' http://localhost:8000' )
339
+ -browser.get(" http://localhost:8000" )
339
340
+class NewVisitorTest(unittest.TestCase):
340
341
341
- -assert ' Django' in browser.title
342
+ -assert " Django" in browser.title
342
343
+ def setUp(self):
343
344
+ self.browser = webdriver.Firefox()
344
345
+
0 commit comments