Django

Code

Ticket #7165 (closed: fixed)

Opened 4 months ago

Last modified 3 months ago

Include an assertNotContains for responses

Reported by: pupeno@pupeno.com Assigned to: nobody
Milestone: Component: Unit test system
Version: SVN Keywords: test
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 1
Needs tests: 1 Patch needs improvement: 0

Description

Hello,

I've wrote an assertNotContains for the TestCase? for testing that something is not present in the output in a response. Essentially the reverse of assertContains. The patch will be attached.

Thanks.

Attachments

assert_not_contains.diff (1.0 kB) - added by J. Pablo Fernandez <pupeno@pupeno.com> on 05/03/08 21:36:47.
assert_not_contains.2.diff (2.4 kB) - added by J. Pablo Fernandez <pupeno@pupeno.com> on 05/04/08 07:27:09.
Assertion with test and documentation.

Change History

05/03/08 21:36:47 changed by J. Pablo Fernandez <pupeno@pupeno.com>

  • attachment assert_not_contains.diff added.

05/04/08 02:02:14 changed by russellm

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests set to 1.
  • needs_docs set to 1.

You could already do this with assertContains(count=0), but I don't have any particular objection otherwise.

BUT

Needs tests and documentation. Remember people, a patch is almost worthless if it doesn't prove to me that it works, and tells me how to use it.

05/04/08 02:06:24 changed by russellm

  • component changed from Uncategorized to Unit test system.

05/04/08 07:27:09 changed by J. Pablo Fernandez <pupeno@pupeno.com>

  • attachment assert_not_contains.2.diff added.

Assertion with test and documentation.

05/04/08 07:30:26 changed by J. Pablo Fernandez <pupeno@pupeno.com>

There it is with test and documentation. I wanted to check that the code was acceptable before putting more time on it. If you need more tests or a different documentation, let me know and I'll try to do it.

I actually haven't thought about count=0 because I almost never use count, but even then I think using NotContains?() is more readable than Contains(count=0), and tests can always use some improvements in readability. Also I was thinking if maybe this has to be thin wrapper to Contains(count=0), but then, the error message would not be as informative. What do you think?

06/06/08 08:50:03 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [7578]) Fixed #7165 -- Added an assertNotContains() method to the test client. Thanks for the suggestion and implementation, J. Pablo Fernandez <pupeno@pupeno.com>.


Add/Change #7165 (Include an assertNotContains for responses)




Change Properties
Action