Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various broken or nonsensical behaviors with h-matchers's fluent interface #79

Open
seanh opened this issue Jun 13, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@seanh
Copy link
Contributor

seanh commented Jun 13, 2024

This would probably be better as multiple separate issues if we actually planned to fix them, but I I'm writing this more for reference because I'm thinking of deprecating h-matchers rather than fixing these issues.

>>> # This should assert that the left-hand-side contains 1, 2, 3 and 4.
>>> # In fact it does not raise even though 1, 2, and 3 are missing.
>>> assert [4] == Any.list.containing([1,2,3]).containing([4])

>>> # It makes no sense to call Any.list.only() (rather than Any.list.contains([...]).only()).
>>> # This should raise a sensible exception but raises a bizarre one.
>>> assert [] == Any.list.only()
-> TypeError: ContainsMixin.only() missing 1 required positional argument: 'self'

>>> # It's redundant to call Any.list.comprised_of(n).only() but it should just
>>> # work and be equivalent to Any.list.comprised_of(n).
>>> # Instead if gives an unclear exception.
>>> assert [1,1,1] == Any.list.comprised_of(1).only()
-> ValueError: You must set items before calling this

The fluent interface style leads to a combinatorial explosion that inevitably opens up all kinds of unforeseen combinations. I bet there’s lots more of these.

@seanh seanh added the bug Something isn't working label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant