Method all_elements using AllElementsMatcher match sucessfully (but incorrectly IMO), when provided iterable is empty.
Example:
# I want to test this method
def get_alive_objects():
return [obj for obj in objects if obj.is_alive] # This returns empty list, because all objects are dead
some_list = get_alive_objects()
assert_that(
some_list,
all_elements(
has_attrs(
is_alive=True))
)
Result: Matched
IMO this should throw an error that iterable is empty like, but you want to match something (like in other Matchers in iterable_matchers.py.)
For example IncludesMatcher
This is intended behaviour, by analogy with the universal quantifier, or the behaviour of all in Python. If you want to check that the iterable is non-empty, you'll need to check for that explicitly.
Method
all_elements
usingAllElementsMatcher
match sucessfully (but incorrectly IMO), when provided iterable is empty.Example:
Result: Matched
IMO this should throw an error that iterable is empty like, but you want to match something (like in other Matchers in iterable_matchers.py.) For example IncludesMatcher
I can prepare PR for that if I get a greenlight