
import os
import unittest

from splinter import Browser


class TestLoginPage (unittest.TestCase):
    def setUp(self):
        self.browser = Browser('phantomjs')

    def test_login_page_appears(self):
        # This needs to come from an environment variable at some point
        # For now, this will only pass if the lighthouse-app-server host is
        # running.
        url = "http://%s/login" % os.environ['LIGHTHOUSE_HOST']
        title = 'Lighthouse'

        self.browser.visit(url)

        self.assertEqual(self.browser.url, url)
        self.assertEqual(self.browser.status_code.code, 200)
        self.assertIn(self.browser.title, title)

        self.assertIn('Login with ID.', self.browser.html)


import os
import unittest

from splinter import Browser


class TestLoginPage (unittest.TestCase):
    def setUp(self):
        self.browser = Browser('phantomjs')

    def test_login_page_appears(self):
        # This needs to come from an environment variable at some point
        # For now, this will only pass if the lighthouse-app-server host is
        # running.
        url = "http://%s/login" % os.environ['LIGHTHOUSE_HOST']
        title = 'Lighthouse'

        self.browser.visit(url)

        self.assertEqual(self.browser.url, url)
        self.assertEqual(self.browser.status_code.code, 200)
        self.assertIn(title, self.browser.title)

        self.assertIn('Login with ID.', self.browser.html)

Check that expected title exists in the actual title, not the other way round
Check that expected title exists in the actual title, not the other way round

  
  import os
  import unittest
  
  from splinter import Browser
  
  
  class TestLoginPage (unittest.TestCase):
      def setUp(self):
          self.browser = Browser('phantomjs')
  
      def test_login_page_appears(self):
          # This needs to come from an environment variable at some point
          # For now, this will only pass if the lighthouse-app-server host is
          # running.
          url = "http://%s/login" % os.environ['LIGHTHOUSE_HOST']
          title = 'Lighthouse'
  
          self.browser.visit(url)
  
          self.assertEqual(self.browser.url, url)
          self.assertEqual(self.browser.status_code.code, 200)
-         self.assertIn(self.browser.title, title)
+         self.assertIn(title, self.browser.title)
  
          self.assertIn('Login with ID.', self.browser.html)
  
Check that expected title exists in the actual title, not the other way round
## Code Before:

import os
import unittest

from splinter import Browser


class TestLoginPage (unittest.TestCase):
    def setUp(self):
        self.browser = Browser('phantomjs')

    def test_login_page_appears(self):
        # This needs to come from an environment variable at some point
        # For now, this will only pass if the lighthouse-app-server host is
        # running.
        url = "http://%s/login" % os.environ['LIGHTHOUSE_HOST']
        title = 'Lighthouse'

        self.browser.visit(url)

        self.assertEqual(self.browser.url, url)
        self.assertEqual(self.browser.status_code.code, 200)
        self.assertIn(self.browser.title, title)

        self.assertIn('Login with ID.', self.browser.html)

## Instruction:
Check that expected title exists in the actual title, not the other way round
## Code After:

import os
import unittest

from splinter import Browser


class TestLoginPage (unittest.TestCase):
    def setUp(self):
        self.browser = Browser('phantomjs')

    def test_login_page_appears(self):
        # This needs to come from an environment variable at some point
        # For now, this will only pass if the lighthouse-app-server host is
        # running.
        url = "http://%s/login" % os.environ['LIGHTHOUSE_HOST']
        title = 'Lighthouse'

        self.browser.visit(url)

        self.assertEqual(self.browser.url, url)
        self.assertEqual(self.browser.status_code.code, 200)
        self.assertIn(title, self.browser.title)

        self.assertIn('Login with ID.', self.browser.html)
