added is_subset_of() for testing set comparison#48
added is_subset_of() for testing set comparison#48mario-campos wants to merge 2 commits intoassertpy:masterfrom mario-campos:is_subset_of
Conversation
|
Regarding the 98% code coverage, that was reduced by 1.5% because I added more code to the code base, but if you examine closely, you'll see my additions are covered by my unit tests. And regarding the Travis-CI error, you'll see the test cases pass 3/4 times. The one that failed was due to a failure in |
|
@mario-campos the This already works: assert_that(1).is_in(0,1,2,3)
assert_that(1).is_not_in(-1,-2,-3)Extend to lists and sets? assert_that([1,2,3]).is_in([1,2,3,4])
assert_that(set([1,2,3])).is_in(set([1,2,3,4])) |
|
Yeah, that'll work too. I'll commit some more. |
|
I tried to extend assert_that({1,2,3}).is_in({}, {1}, {1,2}, {1,2,3,4})because The same can be said for lists: does this evaluate to true or false? assert_that([1,2,3]).is_in([], [1,2], [1,2,3,4])False if you're expecting I think, by conflating |
|
@mario-campos agreed, went back to Works on anything iterable: assert_that(['a','b','c']).is_subset_of(['a','b','c','d'])
assert_that((1,2,3)).is_subset_of((1,2,3,4))
assert_that('foo').is_subset_of('abcdefghijklmnopqrstuvwxyz')
assert_that({1,2,3}).is_subset_of({1,2,3,4})And if given multiple superset args, they are flattened together: assert_that(['a','b','c']).is_subset_of('a', ['b','c'])
assert_that({1,2,3}).is_subset_of({1,2}, {3,4}) |
|
Thanks! |
Currently, the way to test for subsets is a little roundabout:
With this Pull Request, it's a bit cleaner: