Python AttributeError in Testing Goat -


i've started working through test-driven development python , don't understand attributeerror i'm getting it's different 1 in book.

the code run selenium test is:

from selenium import webdriver import unittest  class new_visitor_test(unittest.testcase):          def set_up(self):                 self.browser = webdriver.firefox()          def tear_down(self):                 self.browser.quit()          def test_can_start_a_list_and_retrieve_it_later(self):                 self.browser.get('http://localhost:8000')                  self.assertin('to-do', self.browser.title)                 self.fail('finish test!')  if __name__ == '__main__':         unittest.main(warnings='ignore') 

and error should be:

traceback (most recent call last): file "functional_tests.py", line 18, in test_can_start_a_list_and_retrieve_it_later self.assertin('to-do', self.browser.title) assertionerror: 'to-do' not found in 'welcome django' 

the error is:

traceback (most recent call last):   file "functional_tests.py", line 13, in test_can_start_a_list_and_retrieve_it_later     self.browser.get('http://localhost:8000') attributeerror: 'new_visitor_test' object has no attribute 'browser' 

what's causing error?

the setup method should called setup(), tear down method - teardown():

class new_visitor_test(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):         self.browser.get('http://localhost:8000')          self.assertin('to-do', self.browser.title)         self.fail('finish test!') 

the methods named correctly in book.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -