... | ... | @@ -38,9 +38,13 @@ class MyPageTest(ResponseDiffTestMixin, test.TestCase): |
|
|
self.selector_test('table.mandates tr')
|
|
|
```
|
|
|
|
|
|
Each call to `assertResponseDiffEmpty` with a selector will extract all elements that match the selector, and compare them to a fixture (it will create the fixture and fail on first run). You can also omit the selector, in which case the whole response (ie. the whole html page) will be tested -- don't overuse this, because then page header changes will make many tests fail.
|
|
|
Each call to `assertResponseDiffEmpty` with a selector will extract all elements that match the selector, and compare them to a fixture (it will create the fixture and fail on first run).
|
|
|
|
|
|
Please also ensure you include database query tests to prevent performance regressions. Use `TestCase.assertNumQueries` and *specify which queries are expected* as follows:
|
|
|
Here are some guidelines for testing templates:
|
|
|
* Don't test for "static" HTML (ie. HTML that is rendered straight from templates).
|
|
|
* Do test for dynamically-generated HTML, eg. for loops
|
|
|
* Avoid writing tests without selectors (ie. full-page tests). Those will all fail as soon as a header change is made (or as soon as a collected static resource, such as CSS or JS, changes).
|
|
|
* Also ensure you include database query tests to prevent performance regressions. Use `TestCase.assertNumQueries` and *specify which queries are expected* as follows:
|
|
|
|
|
|
|
|
|
```python
|
... | ... | |