-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make assertion logging for compairsons more helpful? #80
Comments
Ironically, the "current example" was easier for me to find the error in because the substring was closer to the almost-matching substring in the non-matching string. But i do get what you're getting at. Removing the "a string containing" part of the failed assertion message will lose valuable information, though. In your changed example, i would assume we were looking for an exact match. You're right, we'd probably have to make that change in Hamcrest, or make custom versions of all of the matchers we want this to affect. Then we could sub in the changed mismatch string, maybe just have the objects under test on their own lines?
|
I updated the example to illustrate a little better. |
Or something like this:
I would guess two lines might be a better solution though. |
Maybe for strings we could make something even more tester-friendly and use That could produce output like this:
This is what i did: >>> ndiff('editable category\nCategory Code: EDITCAT\nClass Type:\nClass Code:\nDescription:\nIndirect\nEDITCLASS\nJob Category to be edited\nEdit\nACTIVE'.splitlines(keepends=True), 'editable category\nCategory Code: EDITCAT\nClass Type:\nClass Code:\nDescription:\nIndirect\nEDITCLASS\neditable category\nEdit\nACTIVE'.splitlines(keepends=True))
<generator object Differ.compare at 0x105269f80>
>>> [x for x in _]
[' editable category\n', ' Category Code: EDITCAT\n', ' Class Type:\n', ' Class Code:\n', ' Description:\n', ' Indirect\n', ' EDITCLASS\n', '- Job Category to be edited\n', '+ editable category\n', ' Edit\n', ' ACTIVE'] We could then check which entries in the diff results start with |
Using diff tools can be really tricky depending on the differences especially when it comes to patterns etc. I started to suggest we opt for displaying the visual differences to avoid possible confusion, but I got to wondering if this is something that should be able to customize to their need? |
Users can already customize it to their need by doing the exact thing that i'm suggesting we do, haha. :P |
I submitted a ticket to hamcrest: hamcrest/PyHamcrest#235 |
Since we've got the issue open in PyHamcrest, i'll close this one here. They have it marked as a "good first issue," maybe i'll take it on or something! |
This may not even be possible at the screenpy level and perhaps it's something we pass along to hamcrest.....
It sure would be nice if the failed assert comparing two strings would line up the strings to make it easier to identify where the difference lies.
Here is a current example of two large strings that do not match.
It'd be nice if it looked something more like this:
The text was updated successfully, but these errors were encountered: