File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
benchmarks/test_utils_benchmarks.py Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ from django .forms import CharField , Form
2+ from django .test import SimpleTestCase
3+
4+ from ...utils import bench_setup
5+
6+
7+ class DummyForm (Form ):
8+ name = CharField ()
9+
10+
11+ class Assertions :
12+ def setup (self ):
13+ bench_setup ()
14+ self .html = "<div><p>Hello <strong>World</strong></p></div>"
15+ self .response_content = "<html><body><h1>Welcome</h1><p>Test</p></body></html>"
16+ self .form = DummyForm (data = {})
17+ self .test_case = SimpleTestCase ()
18+
19+ def time_assertContains (self ):
20+ self .test_case .assertContains (self .response_content , "Welcome" )
21+
22+ def time_assertNotContains (self ):
23+ self .test_case .assertNotContains (self .response_content , "Goodbye" )
24+
25+ def time_assertFormError (self ):
26+ self .form .is_valid ()
27+ self .test_case .assertFormError (self .form , "name" , "This field is required." )
28+
29+ def time_assertInHTML (self ):
30+ self .test_case .assertInHTML ("<p>Hello <strong>World</strong></p>" , self .html )
31+
32+ def time_assertNotInHTML (self ):
33+ self .test_case .assertNotInHTML ("<strong>Django</strong>" , self .html )
You can’t perform that action at this time.
0 commit comments