Skip to content

Builtin: Add case-insensitivity support to comparison keywords #2439

Closed

Description

@HelioGuilherme66

For reference see topic on google group.

(...) Perhaps it could work like this:

Should Be Equal    ${string}    expected    ignore_case=True
Should Contain    ${list}    expected    ignore_case=True
  • Must be backward compatible (default value as before)
  • Must have Unit Tests expanded for new option.

Update by @pekkaklarck:

These keywords should get the new ignore_case argument:

Activity

  1. pekkaklarck commented on Sep 2, 2016

    @pekkaklarck
    Member

    Yes, this would be nice. If someone is interested to implement this, I'm willing to review PRs. This shouldn't cause backwards compatibility issues so the enhancement can be included to any release. The first step would be listing affected keywords in BuiltIn, String, and possibly in other libraries.

    Few things to take into account:

    • I'd prefer acceptance tests over unit tests
    • Need to decide what is the name of the new option. ignore_case is my current favorite, but could also consider e.g. case_insensitive (longer) and caseless (shorter but not real word).
    • What to do if value is not a string? I think it would be best to leave the value as-is.
  2. chriscallan commented on Sep 16, 2016

    @chriscallan
    Contributor

    Doesn't look like it would be too difficult to implement this, although it could be a death by 1000 cuts if implemented everywhere that a string "could" be used.
    It would seem that adding a case insensitivity option to generic methods like "Should Be Equal" may be a bit error prone with the assumptions about the values sent in. I think that adding the case sensitivity option to only "Should Be Equal As Strings" is a more logical, and limited, way to implement this functionality while limiting the assumptions about values being passed in.
    Besides, hasn't the consumer of this keyword already declared that they want to compare as strings by indicating they want to do a case-insensitive comparison? :-)
    I'd be happy to take this on, preferably the more limited approach I've suggested.

  3. pekkaklarck commented on Sep 20, 2016

    @pekkaklarck
    Member

    I agree adding this functionality to each and every keyword possibly operating with strings can be too big a task. Better to add this to the most important keywords only and then add it to new keywords later if needed. That said, I think there are quite many important keywords that ought to get this functionality from the beginning:

    • Should Be Equal (this is the most common comparison keyword and most often used with strings)
    • Should Be Equal As Strings
    • Should Contain
    • Should Match
    • Should Match Regexp (should probably compile the pattern with re.IGNORECASE option in this case)

    These would be nice too:

    • Should Start With
    • Should End With

    Also the "Not" versions of the above keywords (e.g. "Should Not Be Equal") should probably support this. Any other keyword people think are important?

    Although I'd like to see all these added together in one release, I'd prefer them to be implemented as separate PRs. That would split the implementation workload and also make reviewing easier. Probably it would be best to have a PR for each keyword and its "Not" version.

  4. chriscallan commented on Sep 20, 2016

    @chriscallan
    Contributor

    Glad to see we're on the same page. That was the same list of keywords that I came up with during my research, and it was short enough to not seem overly daunting.
    I'll get started on this today and should have something for you to review in the very near future.

  5. pekkaklarck commented on Sep 20, 2016

    @pekkaklarck
    Member

    Awesome! Please submit a PR with only one or two kws first. If there are things to fix, you can then avoid those issues in latter PRs.

  6. chriscallan commented on Sep 20, 2016

    @chriscallan
    Contributor

    I'm having some troubles with the pull request for the first two keywords. Getting "403 Permission Denied" messages when doing the push, or trying to.
    I haven't done any Pull Requests through github before, so not sure if there are any permissions that need to be set or if I'm just doing something wrong :-)
    Any ideas on what the issue might be here?

  7. pekkaklarck commented on Sep 20, 2016

    @pekkaklarck
    Member

    Did you look at CONTRIBUTING.rst? In addition to project specific stuff, it has links to GitHub docs about PRs etc. The highlevel workflow is like this:

    1. Create your own fork and clone it locally.
    2. Make a topic branch for these changes. Commit changes to the branch and push them to GitHub.
    3. Create a PR based on the branch on GitHub.
  8. chriscallan commented on Sep 22, 2016

    @chriscallan
    Contributor

    Thanks for pointing me in the right direction :-) Working with GitHub projects is a bit different than I'm used to.
    I think I've got the pull request setup properly and that I've got the acceptance test cases worked out.
    Just the "Should Be Equal", "Should Be Equal As Strings" keywords.

  9. pekkaklarck commented on Sep 22, 2016

    @pekkaklarck
    Member

    Yeah, GitHub and Git have their learning curves (I'm definitely not a master myself!) but they are so ubiquitous that learning them helps also with other projects. The PR #2447 seems to be setup just fine and also looks pretty good. There were some smallish things I hope you could fix, though, and I added comments to the PR itself. Thanks for your work so far and let me know there or here if you have any questions about the comments!

  10. chriscallan commented on Sep 27, 2016

    @chriscallan
    Contributor

    Not sure if you saw my latest PR for this. Includes the rest of the keywords and acceptance test cases. Didn't want to ping you via message in case you were already alerted when PR's are submitted.

  11. pekkaklarck commented on Sep 30, 2016

    @pekkaklarck
    Member

    Hi, I saw updates but been busy with a training trip. I ought to have time to concentrate on RF 3.0.1 more next week. Why did you close PR #2447? Are you planning to create a new one?

  12. chriscallan commented on Sep 30, 2016

    @chriscallan
    Contributor

    I had closed PR #2447 and opened another because it seemed easier to close that one down, make the additional changes and start a fresh PR. I opened #2450 with the entire set of changes.

  13. added this to the 3.0.1 milestone on Oct 5, 2016
  14. 1 remaining item

  15. self-assigned this
    on Dec 30, 2016
  16. changed the title [-]String and Builtin libraries: Enhance string comparison keywords by adding ignore case option[/-] [+]Builtin: Add case-insensitivity support to comparison keywords[/+] on Dec 30, 2016
  17. pekkaklarck commented on Dec 30, 2016

    @pekkaklarck
    Member

    Decided not to add this support to Should (Not) Match Regexp. They already support embedding case-insensitivity flag into the pattern. If we add explicit case-insensitivity support, should consider adding support also for other regexp flags.

  18. pekkaklarck commented on Dec 30, 2016

    @pekkaklarck
    Member

    All the keywords listed in the original description now have got ignore_case=False option. I'm not entirely happy about error reporting (see my comment above), but don't have time to enhance it now. I'll submit a separate issue about that for RF 3.1.

  19. pekkaklarck commented on Dec 30, 2016

    @pekkaklarck
    Member

    Enhancing error reporting is #2512. This issue can be considered done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions