expect_not_contains()
and expect_not_in()
#2239
Open
+151
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces two negated expectations as suggested in #1851 with the following functionality:
expect_not_contains(x, y)
tests thatx
contains none of the elements ofy
(i.e.y
is disjoint fromx
).expect_not_in(x, y)
tests that no element ofx
is iny
(i.e.x
is disjoint fromy
).While the not negated expectations actually do something different, these two are equivalent. It might still make sense to have them both.
During implementation I realised that one might have different expectations from these names. For example, one might expect that
expect_not_in(x, y)
checks that:x
are iny
(which is what I implemented)x
is not a subset ofy
Both of them could also meaningfully be understood as inversions of the other two expectations. Would the second variant also be of interest?
Let me know if anything should be improved.