diff --git a/wagtail/test/utils/wagtail_tests.py b/wagtail/test/utils/wagtail_tests.py index fc738f9a82f0..51499c4f4c41 100644 --- a/wagtail/test/utils/wagtail_tests.py +++ b/wagtail/test/utils/wagtail_tests.py @@ -1,12 +1,54 @@ import warnings from contextlib import contextmanager +from bs4 import BeautifulSoup from django import VERSION as DJANGO_VERSION from django.contrib.auth import get_user_model +from django.test.client import Client as DjangoTestClient from django.test.testcases import assert_and_parse_html +from django.utils.functional import SimpleLazyObject + + +class BS4SoupClient(DjangoTestClient): + """Convenience wrapper around Django's Client and BeautifulSoup's SoupSieve + + The intend of this wrapper is to make it easier to check the html of a response. + + Usage example: + + client = BS4SoupClient() + response = client.get("/good-vibes/") + + # Select a HTML