issue with matchers methods

11 views
Skip to first unread message

mam-p

unread,
May 14, 2013, 1:57:26 PM5/14/13
to Saunter
Are any pysaunter users using the matchers methods successfully? In
our use of pysaunter 0.54, I'm seeing a problem with verify_true/
assert_true when the condition is false. If these methods are working
properly in a later version, that'd be cool to know. If you figured
out a workaround, that would also be cool to know. And Adam--if you
could look into this issue and produce a new matchers.py whose
location I could drop into my PYTHONPATH, that'd be the coolest of
all!

I filed https://github.com/Element-34/py.saunter/issues/44 about the
problem.

--mam-p

Dakota Smith

unread,
May 14, 2013, 3:20:40 PM5/14/13
to sau...@googlegroups.com
I'm crossing the streams on this one. I first responded on GitHub, but the GGroup is likely a better avenue for the rest of my response. Here is my first response:


As a follow up, I created a couple of methods using verify_true. 


Running those gives more indication as to what I expect from matchers. I may be wrong, but I'll explain my approach to using them.

When I am using a verify_ method, I try to separate that from any evaluation I can do. Additionally, I make a point to use the appropriate method. So for example if I were expecting to compare to integers, I would use

matchers.verify_equal(expected_number, result_value, "Resultant number of this thing does not match expected number of this thing")

I also use the message to communicate with other humans, so we should begrudgingly make it obvious and understandable by them. Following that, I would only use a verify_true if I were assessing the value of a boolean.

result = self.do_something_successfully() # assuming that returns a boolean.
matchers.verify_true(result, "I did that thing and it was supposed to return a true, but it was false.)

To put that together into my gist examples, if I were actually doing something along these lines, I would:

When using verify_true, use methods to evaluate expectations vs reality, have these methods return boolean values. (I like the word is_ ). 
Write verbose messages that describe the conditions I expected when calling verify_true on this value.
Use verify_equal or verify_in when attempting to determine if a dictionary, or values in a dictionary match expectations.

Not knowing the specifics makes it a bit harder to understand where the problem comes up for you, but hopefully some of that can be applied to get you going. 


--mam-p

--
You received this message because you are subscribed to the Google Groups "Saunter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to saunter+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Dakota Smith

unread,
May 14, 2013, 4:27:29 PM5/14/13
to sau...@googlegroups.com
This will teach me to start responding in two places. Sheesh. 

I've updated my response on GitHub, and I added a new example for tracking this down some more.

Here is a solution that seems to work on my end.

Use matchers.verify_equal() as you were in your examples, but instead of using the matchers.assert_equal() method, just use assert, i.e.

assert value==othervalue

That halted my test and raised an exception just fine for me, reported a failure and gave me a stacktrack on the assert.
Reply all
Reply to author
Forward
0 new messages