#34658: New assertion `assertNotInHTML`, like `assertContains` has
`assertNotContains`
-------------------------------------+-------------------------------------
               Reporter:  Thibaud    |          Owner:  nobody
  Colas                              |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Testing    |        Version:
  framework                          |       Keywords:  testcases, unit
               Severity:  Normal     |  tests, HTML, assertions, testing
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Django’s test assertions have `assertContains` and `assertNotContains`
 which are HTML-aware ways to check what’s inside a response, similar to
 Python’s `assertIn` and `assertNotIn`. Django also offers `assertInHTML` –
 but there is no `assertNotInHTML`.

 This is very straightforward to implement – and I suspect more than a few
 projects will already have their own implementation if they need this, but
 I think it’d make much more sense to have this out of the box considering
 other "<needle> in <haystack>" assertions have their `-not` equivalent
 built in. For me, the main source of pain here is that I use this often
 enough to use this but rarely enough to frequently forget:

 - Whether this is a Django built-in or not. So I look at
 [https://docs.djangoproject.com/en/4.2/topics/testing/tools/#assertions
 assertions docs] and am surprised not to see it.
 - Whether the project I work on has it or not. So again I have to look
 around and potentially add it.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34658>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070188c4739c32-68cfdf42-4e05-4611-93b0-ad93d58ae644-000000%40eu-central-1.amazonses.com.

Reply via email to