Opened 8 years ago

Closed 8 years ago

#7165 closed (fixed)

Include an assertNotContains for responses

Reported by: pupeno@… Owned by: nobody
Component: Testing framework Version: master
Severity: Keywords: test
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

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 (2)

assert_not_contains.diff (1.0 KB) - added by J. Pablo Fernandez <pupeno@…> 8 years ago.
assert_not_contains.2.diff (2.4 KB) - added by J. Pablo Fernandez <pupeno@…> 8 years ago.
Assertion with test and documentation.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by J. Pablo Fernandez <pupeno@…>

Attachment: assert_not_contains.diff added

comment:1 Changed 8 years ago by Russell Keith-Magee

Needs documentation: set
Needs tests: set
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

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.

comment:2 Changed 8 years ago by Russell Keith-Magee

Component: UncategorizedUnit test system

Changed 8 years ago by J. Pablo Fernandez <pupeno@…>

Attachment: assert_not_contains.2.diff added

Assertion with test and documentation.

comment:3 Changed 8 years ago by J. Pablo Fernandez <pupeno@…>

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?

comment:4 Changed 8 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top