mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Change WagtailTestUtils.get_soup() to accept str/bytes instead of HttpResponse
This commit is contained in:
parent
cfa4b7ca69
commit
ad070af8fd
@ -18,7 +18,7 @@ Changelog
|
||||
* Maintenance: Remove unused WorkflowStatus view, urlpattern, and workflow-status.js (Storm Heg)
|
||||
* Maintenance: Add support for options/attrs in Telepath widgets so that attrs render on the created DOM (Storm Heg)
|
||||
* Maintenance: Update pre-commit hooks to be in sync with latest changes to Eslint & Prettier for client-side changes (Storm Heg)
|
||||
* Maintenance: Add `WagtailTestUtils.get_soup()` method to get a `BeautifulSoup` object from an `HttpResponse` object (Storm Heg)
|
||||
* Maintenance: Add `WagtailTestUtils.get_soup()` method for testing HTML content (Storm Heg, Sage Abdullah)
|
||||
* Maintenance: Allow `ViewSet` subclasses to customise `url_prefix` and `url_namespace` logic (Matt Westcott)
|
||||
* Maintenance: Simplify `SnippetViewSet` registration code (Sage Abdullah)
|
||||
|
||||
|
@ -37,7 +37,7 @@ depth: 1
|
||||
* Remove unused WorkflowStatus view, urlpattern, and workflow-status.js (Storm Heg)
|
||||
* Add support for options/attrs in Telepath widgets so that attrs render on the created DOM (Storm Heg)
|
||||
* Update pre-commit hooks to be in sync with latest changes to Eslint & Prettier for client-side changes (Storm Heg)
|
||||
* Add `WagtailTestUtils.get_soup()` method to get a `BeautifulSoup` object from an `HttpResponse` object (Storm Heg)
|
||||
* Add `WagtailTestUtils.get_soup()` method for testing HTML content (Storm Heg, Sage Abdullah)
|
||||
* Allow `ViewSet` subclasses to customise `url_prefix` and `url_namespace` logic (Matt Westcott)
|
||||
* Simplify `SnippetViewSet` registration code (Sage Abdullah)
|
||||
|
||||
|
@ -364,7 +364,7 @@ class TestPrivacyIndicators(WagtailTestUtils, TestCase):
|
||||
# Check the response
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
soup = self.get_soup(response)
|
||||
soup = self.get_soup(response.content)
|
||||
|
||||
# Check the private privacy indicator is visible
|
||||
private_indicator = soup.select_one("[data-privacy-sidebar-private]")
|
||||
|
@ -1,17 +1,17 @@
|
||||
import warnings
|
||||
from contextlib import contextmanager
|
||||
from typing import Union
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from django import VERSION as DJANGO_VERSION
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.http import HttpResponse
|
||||
from django.test.testcases import assert_and_parse_html
|
||||
|
||||
|
||||
class WagtailTestUtils:
|
||||
@staticmethod
|
||||
def get_soup(response: HttpResponse, parser="html.parser") -> BeautifulSoup:
|
||||
return BeautifulSoup(response.content, parser)
|
||||
def get_soup(markup: Union[str, bytes], parser="html.parser") -> BeautifulSoup:
|
||||
return BeautifulSoup(markup, parser)
|
||||
|
||||
@staticmethod
|
||||
def create_test_user():
|
||||
|
Loading…
Reference in New Issue
Block a user