1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #5016: assertHttpStatus() should report form validation errors

This commit is contained in:
Jeremy Stretch
2020-08-18 17:02:47 -04:00
parent 0d9fc309d5
commit 3ebef04a11
3 changed files with 32 additions and 29 deletions

View File

@ -1,4 +1,5 @@
import logging
import re
from contextlib import contextmanager
from django.contrib.auth.models import Permission, User
@ -43,6 +44,14 @@ def create_test_user(username='testuser', permissions=None):
return user
def extract_form_failures(content):
"""
Given raw HTML content from an HTTP response, return a list of form errors.
"""
FORM_ERROR_REGEX = r'<!-- FORM-ERROR (.*) -->'
return re.findall(FORM_ERROR_REGEX, str(content))
@contextmanager
def disable_warnings(logger_name):
"""