Thanks to visit codestin.com
Credit goes to github.com

Skip to content

First 2 keywords for case-insensitive string comparison #2447

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

Closed
wants to merge 26 commits into from
Closed

First 2 keywords for case-insensitive string comparison #2447

wants to merge 26 commits into from

Conversation

chriscallan
Copy link
Contributor

…rings" perform string compares case-insensitively; (#1)

Modified the Acceptance tests affected by the above 2 keywords;
Added an Acceptance test to prove out the case-insensitive string comparison;

krizex and others added 4 commits August 31, 2016 14:46
…rings" perform string compares case-insensitively;

Modified the Acceptance tests affected by the above 2 keywords;
Added an Acceptance test to prove out the case-insensitive string comparison;
…rings" perform string compares case-insensitively; (#1)

Modified the Acceptance tests affected by the above 2 keywords;
Added an Acceptance test to prove out the case-insensitive string comparison;
Copy link
Member

@pekkaklarck pekkaklarck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good already. Fixing tests that are broken due to new argument is a very good catch.

I added some comments about things I hope could be changed. Most of them are pretty minor and something you couldn't possibly know beforehand. The only real bug seems to be using str().

@@ -74,6 +74,10 @@ Should Not Be Equal with bytes containing non-ascii characters
Should Not Be Equal ${BYTES WITH NON ASCII} unicode
Should Not Be Equal ${BYTES WITH NON ASCII} ${BYTES WITH NON ASCII}

Should Be Equal With Case Insensitivity
Should Be Equal "test value" "TEST VALUE" ignore_case=True
Should Be Equal As Strings "test value" "TEST VALUE" ignore_case=True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Quotes in the verified text are not necessary and mainly confuse reader.
  • I'd prefer having case-insensitive test after normal Should Be Equal test.
  • Should test also with non-ASCII characters. For example that HYVÄÄ YÖTÄ (good night in Finnish) equals hyvää yötä case-insensitively. Could consider using [Template] like many other tests here.
  • Should Be Equal As Strings should get its own test after normal Should Be Equal As Strings test.

@@ -613,9 +613,16 @@ def should_be_equal(self, first, second, msg=None, values=True):
for example, string ``false`` or ``no values``. See `Boolean arguments`
section for more details.

``ignore_case`` is False by default. It is a boolean value, and if True
indicates that 'first' and 'second' should be compared case-insensitively,
provided that 'first' and 'second' are string types.
Copy link
Member

@pekkaklarck pekkaklarck Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Docs should refer to Boolean arguments section about possible values for ignore_case. You can check how other keywords here do it. Values should also be handled according to that section, but more about that below.
  • Should use double-backticks style also with arguments first and second.
  • Should add a note that this is a new feature in Robot Framework 3.0.1.

If both arguments are multiline strings, the comparison is done using
`multiline string comparisons`.
"""
if ignore_case and is_string(first) and is_string(second):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use is_truthy(ignore_case) similarly as other keywords accepting Boolean values. See also the previous comment about docs referring to Boolean arguments section.

If both arguments are multiline strings, the comparison is done using
`multiline string comparisons`.
"""
if ignore_case and is_string(first) and is_string(second):
first = str(first).lower()
second = str(second).lower()
Copy link
Member

@pekkaklarck pekkaklarck Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must not use str() here because it won't handle non-ASCII characters in Python 2. If we know values are strings, we can simply do first = first.lower(). Adding a test for non-ASCII stuff like I proposed in another comment is a good idea.

pekkaklarck and others added 22 commits September 22, 2016 23:59
PR #2438 by @krizex already fixed the problem with settings preserving
some date between runds he had reported as #2437. This commit slightly
cleans up the code and unit tests in the PR. A new unit/integration
test to validate the real problem with --rerunfailed that this problem
caused is added too.
Added Pygments styles and configured docutils to be compatible with
them.  Embedding Pygments styles to all Libdoc outputs may be a bit
questionable, but they are small enough that I don't think it is a
real problem. We may also later add syntax highlighting to Libdoc's
default syntax too.

Also made background color used by examples etc. in Libdoc outputs and
also in logs and reports a little lighter. Syntax highlighting looks
better on a little lighter background and this background color is
used also in the User Guide.
No need to use external Robot lexer anymore now that Pygments 2.1
suppors all new features.

Also made it an error to use invalid syntax highlight language.
…bles, such that returned messages match the currently expected output (e.g. "FAIL: 'test' != 'TEST1'" rather than"FAIL: 'test' != 'test1'" when the user passed in "TEST1");

Added Acceptance tests for all the keywords affected by the case-insensitivity changes;
PR #2438 by @krizex already fixed the problem with settings preserving
some date between runds he had reported as #2437. This commit slightly
cleans up the code and unit tests in the PR. A new unit/integration
test to validate the real problem with --rerunfailed that this problem
caused is added too.
Added Pygments styles and configured docutils to be compatible with
them.  Embedding Pygments styles to all Libdoc outputs may be a bit
questionable, but they are small enough that I don't think it is a
real problem. We may also later add syntax highlighting to Libdoc's
default syntax too.

Also made background color used by examples etc. in Libdoc outputs and
also in logs and reports a little lighter. Syntax highlighting looks
better on a little lighter background and this background color is
used also in the User Guide.
No need to use external Robot lexer anymore now that Pygments 2.1
suppors all new features.

Also made it an error to use invalid syntax highlight language.
…rings" perform string compares case-insensitively;

Modified the Acceptance tests affected by the above 2 keywords;
Added an Acceptance test to prove out the case-insensitive string comparison;
…bles, such that returned messages match the currently expected output (e.g. "FAIL: 'test' != 'TEST1'" rather than"FAIL: 'test' != 'test1'" when the user passed in "TEST1");

Added Acceptance tests for all the keywords affected by the case-insensitivity changes;
…rings" perform string compares case-insensitively;

Modified the Acceptance tests affected by the above 2 keywords;
Added an Acceptance test to prove out the case-insensitive string comparison;
…bles, such that returned messages match the currently expected output (e.g. "FAIL: 'test' != 'TEST1'" rather than"FAIL: 'test' != 'test1'" when the user passed in "TEST1");

Added Acceptance tests for all the keywords affected by the case-insensitivity changes;
…rings" perform string compares case-insensitively;

Modified the Acceptance tests affected by the above 2 keywords;
Added an Acceptance test to prove out the case-insensitive string comparison;
…bles, such that returned messages match the currently expected output (e.g. "FAIL: 'test' != 'TEST1'" rather than"FAIL: 'test' != 'test1'" when the user passed in "TEST1");

Added Acceptance tests for all the keywords affected by the case-insensitivity changes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants