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:
@ -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):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user