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.
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).
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/*']