Flask-LinkTester

The Flask-LinkTester extension helps test there are no invalid links on a Flask application. This is specially useful for websites, and can also be used as smoke tests for applications.

Installing Flask-LinkTester

Install with pip and easy_install:

pip install Flask-LinkTester

or download the latest version from version control:

git clone https://github.com/sfermigier/flask-linktester.git
cd flask-linktester
python setup.py develop

If you are using virtualenv, it is assumed that you are installing Flask-LinkTester in the same virtualenv as your Flask application(s).

Using

Here’s how you would write your tests:

class CheckLinkTestCase(TestCase):

    def create_app(self):
        ...

    def test_links_from_home(self):
      crawler = LinkTester(self.client, "/")
      crawler.crawl()

If, for some reason, you know some of your links will fail but you want to run the tests anyway, you can blacklist some links by adding:

crawler.black_list |= ['/bad', '/another/bad/*']

Changes

  • 0.2 (2013/10/21)
    • Small cleanups + first release on PyPi.
  • 0.1 (2012/11/03)
    • Extracted and refactored from the Abilian project.

API

class flask_linktester.LinkTester(client, black_list=(), verbosity=0, max_links=100)
crawl(root)

Crawl the application starting from root.

Indices and tables

Fork me on GitHub