-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Collections: Support case-insensitive list and dictionary comparisons #4343
Comments
Sounds good to me. Are you @AllanMedeiros, or someone else, interested to create a PR? Should be pretty straightforward. The only design decision I see is deciding should with dicts this be applied both to keys and values. |
Could something like be ignore_case= [key | value | both] ? |
Options |
Ignore case onlly used for the string type, but in fact, there may be other types of elements in list and dict collection. I.e., list, dict, number, dict inside list, list inside list, etc. |
If the ignore case functionality would be enabled, we obviously should ignore it with non-string values. It should probably be used with nested lists/dicts, though, but that that makes the implementation a bit more complicated. |
Hey, I've been playing around a bit and think I have the ignore_case working for both lists and dictionaries at the moment. It also works for non-string values, so it can also work when a nested list or dict is encountered. I tried to make it as clear as possible, but can imagine that what's clear to me is not clear to everyone. Since this is my first time contributing to something like this I would love to get feedback. I think I also have not be upholding the some standard coding principles (same for the atests). But while I work on that I would like to have some feedback already. If entire sections need to be deleted, I don't have to rework them (to compy with the standards). And I also need to add some documentation about the various ways to use ignore case, as it differs somewhat between keywords. |
I updated the changes in #4690 . Please let me know if there are any more remarks, and whether I should change this from a draft pull request to a regular one |
This commit introduces a new `ignore_case` option to the dictionary comparison methods. When `ignore_case` is set to `True`, the comparison will be case-insensitive for both keys and values. Closes robotframework#4343
Hello, This is my first contribution to the project, and I'm excited to be a part of the community. You can view the details and changes in the pull request here: #4897 Your feedback and thoughts on this would be greatly appreciated. I believe this enhancement could benefit the community by making Dictionary and List comparisons more versatile. Thank you for your valuable suggestion, and I look forward to your feedback. |
Based on a quick look the PR #4690 by @MobyNL looks to be in so good shape after the latest changes that I'll add this issue into RF 7.0 scope. I won't have time to re-review the PR properly right now, but setting the milestone makes sure it won't be forgotten. If you @MobyNL have time, you can update the "New in 6.2" notes to correct version. Because the aforementioned PR is in such a good shape, I closed the newer PR #4897 by @Abhilash-du. I'm sorry for letting the older PR and this issue be open so long that there was confusion about the status. I hope you find something else you can contribute to related to Robot Framework or tool in its ecosystem. |
I'll take a look at it this weekend 👍 |
This was implemented in PR #4690 by @MobyNL. In practice various keywords got new I was doing small cleanup to the new code when I noticed that the library already has some keywords that accept The keywords in Collections already have
Because there are only for keywords, we could pretty easily also add I need to think a bit more about this, but I believe using |
While doing small cleanup to Collections related to this enhancement and otherwise, I noticed that case-insensitive comparisons with dictionaries had some problems. After a bit of investigation it turned out that it is actually pretty complicated problem, especially when we wanted to allow normalizing either only keys and values in addition to normalizing the whole dictionary. Some examples about complexity below:
Getting all the above right wasn't exactly trivial, but after the changes in the above commit everything not ought to work as expected. As part the changes I needed to enhance the I have now also handled the inconsistency with This enhancement is very useful, it showed the inconsistency we had with configuring case-insensitivity, and the new |
This is really awesome! Can't wait to be able to test it, but to be honest I didn't realize it would require that lot of work. This happens all the time on IT world, it doesn't? A feature that seems to be simple to be implemented at first sight and then becomes complex during the development phase. |
Yeah, it's pretty common that something that initially looks simple turns out to be surprisingly complicated. Case-insensitivity with dictionaries was a very good example. You can test the functionality with RF 7.0 alpha 2 that was released few days ago: |
When comparing Lists or Dictionaries would be great if we could ignore case on item, value or both.
Something similar was done in the past with other kws: #2439
This would apply to these kws:
Dictionaries Should Be Equal
Dictionary Should Contain Item
Dictionary Should Contain Key
Dictionary Should Contain Sub Dictionary
Dictionary Should Contain Value
Dictionary Should Not Contain Key
Dictionary Should Not Contain Value
And List kws:
List Should Contain Sub List
List Should Contain Value
List Should Not Contain Duplicates
List Should Not Contain Value
Lists Should Be Equal
The text was updated successfully, but these errors were encountered: