You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above example works and passes the test if put into an assert. i.e. the statement assert mock.call_args_list == expected is valid.
If I want to write the same thing in sure syntax, I get a failure. Let's say I want to write a test with this:
deftest_oh_dear():
# Set up the mock# Interact with the mockexpected= [call(1, 2, 3), call(4, 5, 6), call()]
mock.call_args_list.should.be.equal(expected) # !!! this line fails
The contents of the arrays don't matter. I just find it inconsistent and counter-intuitive syntactically that == works with an assertion and .equal() does not!
The text was updated successfully, but these errors were encountered:
there is nothing exactly "wrong" with sure in this aspect of comparing mock call args list.
What happens is that the "equals" assertion in sure was designed to compare objects and data structures recursively through the DeepComparison class.
I confess that I have come across the same issue you are having, and so I came across this experiment:
frommockimport_CallListasCallListdeftest_oh_dear():
# Set up the mock# Interact with the mockexpected=CallList([call(1, 2, 3), call(4, 5, 6), call()])
mock.call_args_list.should.be.equal(expected) # Success :)
I plan on creating some cool features in sure integrating specifically with mock because it's the best mock library IMHO.
Thanks for clarifying. I take back saying that sure was 'wrong', that was a tad strong =]. You can tell I'm a bit of a novice to Python so that little factoid about DeepComparison was helpful.
I did discover your solution with _CallList but coming from a Haskell/Java/Scala/C# typed-language-land background it feels a bit dirty. So it's great that you're thinking of integrating with mock. I love mocking, mock gets me there but its syntax clunky to use at best.
A fluent interface over setting expectations (like what mockito tried to do) would be absolutely amazing. And a lot of work!
I take this opportunity to thank you for sure because it's made my tests really readable, and it really is the most awesome assertion library Python has today. =]
I really liked the idea, since we're always using sure and mock together. Although, I tend to say that it looks more like a feature request than actually a bug fix.
Anyway, I still think we should give an option to the user bypass this kind of integration. Use case? What if people start using sure to test mock itself? :)
According to the Voidspace mock documentation, you can verify that a method was invoked with specific parameters by doing:
The above example works and passes the test if put into an
assert
. i.e. the statementassert mock.call_args_list == expected
is valid.If I want to write the same thing in
sure
syntax, I get a failure. Let's say I want to write a test with this:The failure I get is:
The contents of the arrays don't matter. I just find it inconsistent and counter-intuitive syntactically that
==
works with an assertion and.equal()
does not!The text was updated successfully, but these errors were encountered: