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.
Comment (by Natalia Bidart):
I fully agree with the rationale, but for this, perhaps, Thibaud could you
please create a forum post to allow for people to present any counter
argument we may not be considering?
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:1>
* status: new => closed
* resolution: => wontfix
Comment:
I'm skeptic. Personally, I find the use of `*NotIn*` assertions really
rare and not the best practice. There can many many reasons why something
is not in something else, and it becomes even more unreliable when we do
this in HTML. It's much more stable and bulletproof to use `*In*`
assertions. I don't think it's worth adding.
Please first start a discussion on the DevelopersMailingList, where you'll
reach a wider audience and see what other think, and
[https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
features/#requesting-features follow the guidelines with regards to
requesting features].
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:2>
Comment (by Thibaud Colas):
Sorry about that, I thought I had read the ticket creation guidelines to
check what the protocol is, but clearly missed the most important bits.
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:3>
* status: closed => new
* resolution: wontfix =>
* stage: Unreviewed => Accepted
Comment:
Accepting based on the [https://forum.djangoproject.com/t/feature-request-
new-assertion-assertnotinhtml-like-assertcontains-has-
assertnotcontains/21711 discussion].
Thibaud, would you like to prepare a patch?
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:4>
* owner: nobody => Thibaud Colas
* status: new => assigned
Comment:
Yes please! Omg I might eventually become a code contributor.
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:5>
* cc: Lemuel Sta Ana (added)
Comment:
Adding myself as CC, I'm very interested to see how the patch for this
will be implemented. Hope you don't mind Thibaud.
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:6>
* owner: Thibaud Colas => evananyonga
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:7>
* cc: Nicolas Lupien (added)
* has_patch: 0 => 1
Comment:
PR https://github.com/django/django/pull/17626
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:8>
* owner: Eva Nanyonga => Nicolas Lupien
* needs_better_patch: 0 => 1
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:9>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:10>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"2bf46c3825ad4ec170324791d6f3a329316ae2d4" 2bf46c38]:
{{{
#!CommitTicketReference repository=""
revision="2bf46c3825ad4ec170324791d6f3a329316ae2d4"
Fixed #34658 -- Added SimpleTestCase.assertNotInHTML().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34658#comment:11>