Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions benchmarks/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"benchmarks.query_benchmarks.query_select_related",
"benchmarks.req_resp_benchmarks.default_middleware",
"benchmarks.req_resp_benchmarks.http_methods",
"benchmarks.test_utils_benchmarks.assertions",
]

SECRET_KEY = "NOT REALLY SECRET"
Expand Down
Empty file.
Empty file.
33 changes: 33 additions & 0 deletions benchmarks/test_utils_benchmarks.py/assertions/benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from django.forms import CharField, Form
from django.test import SimpleTestCase

from ...utils import bench_setup


class DummyForm(Form):
name = CharField()


class Assertions:
def setup(self):
bench_setup()
self.html = "<div><p>Hello <strong>World</strong></p></div>"
self.response_content = "<html><body><h1>Welcome</h1><p>Test</p></body></html>"
self.form = DummyForm(data={})
self.test_case = SimpleTestCase()

def time_assertContains(self):
self.test_case.assertContains(self.response_content, "Welcome")

def time_assertNotContains(self):
self.test_case.assertNotContains(self.response_content, "Goodbye")

def time_assertFormError(self):
self.form.is_valid()
self.test_case.assertFormError(self.form, "name", "This field is required.")

def time_assertInHTML(self):
self.test_case.assertInHTML("<p>Hello <strong>World</strong></p>", self.html)

def time_assertNotInHTML(self):
self.test_case.assertNotInHTML("<strong>Django</strong>", self.html)
Loading