def test_only_valid_links(self):
        """Make sure that all links are valid"""
        settings.LANGUAGE_SECTIONS = ['en']
        user = models.User('user1', 'user1@example.com', 'default')
        user.is_admin = True
        banned_user = models.User('user2', 'user2@example.com', 'default')
        banned_user.is_banned = True
        topic = models.Topic('en', 'This is a test topic', 'Foobar', user)
        post1 = models.Post(topic, user, 'meh1')
        post2 = models.Post(topic, user, 'meh2')
        topic.accept_answer(post1)
        session.commit()

        visited_links = set()
        def visit(url):
            url = urljoin(BASE_URL, url).split('#', 1)[0]
            if not url.startswith(BASE_URL) or visited_links in url:
                return
            visited_links.add(url)
            path = '/' + url.split('/', 3)[-1]
            if path.startswith('/logout?'):
                return
            response = self.client.get(path, follow_redirects=True)
            self.assertEqual(response.status_code, 200)
            for link in html_xpath(response.html, '//html:a[@href]'):
                visit(link.attrib['href'])

        # logged out
        visit('/')
        self.assert_(len(visited_links) > MIN_VISITED)

        # logged in
        visited_links.clear()
        self.login('user1', 'default')
        visit('/')
        self.assert_(len(visited_links) > MIN_VISITED)
dataset/ETHPy150Open mitsuhiko/solace/solace/tests/link_check.py/LinkCheckTestCase.test_only_valid_links/swapped operands of `in`