Skip to content

List ignore - #3469

Merged
pekkaklarck merged 8 commits into
robotframework:masterfrom
bbpatel2001:list_ignore
Feb 28, 2020
Merged

pekkaklarck merged 8 commits into
robotframework:masterfrom
bbpatel2001:list_ignore

Conversation

@bbpatel2001

Copy link
Copy Markdown
Contributor
  1. As list is mutable and if we use sort, it will alter original list. Original list should not be altered so used sorted function instead of sort method.

  2. Instead of modify more lines in the _yield_list_diffs method to handle name option given by user, just passed sorted list to get the diff as we should support name argument/parameter as well.

Comment thread src/robot/libraries/Collections.py Resolved
@bbpatel2001

Copy link
Copy Markdown
Contributor Author

I am working on fixing the tests,

@bbpatel2001

Copy link
Copy Markdown
Contributor Author

@finally all tests passed. Today I learn new thing on test expected value!!!

@bbpatel2001

Copy link
Copy Markdown
Contributor Author

@tysonite @pekkaklarck can you please review.

@laurentbristiel laurentbristiel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just one missing space. Thanks!

Comment thread src/robot/libraries/Collections.py Resolved
@bbpatel2001

Copy link
Copy Markdown
Contributor Author

is this RF 3.2 Candidate ?

Comment thread src/robot/libraries/Collections.py Outdated
else:
sorted_list1 = sorted(list1)
sorted_list2 = sorted(list2)
diffs = list(self._yield_list_diffs(sorted_list1, sorted_list2, names))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks a bit more complicated than needed. AFAIK this would be enough:

if ignore_order:
    list1 = sorted(list1)
    list2 = sorted(list2)

names=None, ignore_order=False):
"""Fails if given lists are unequal.

The keyword first verifies that the lists have equal lengths, and then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The new option needs to be explained in the documentation, possibly with an example. A note about the option being new in Robot Framework 3.2 is needed as well.


Lists Should Be Equal Ignore Order
${names1} = Create List A B C D
${names2} = Create List D B C A

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks a bit strange that the separator between arguments is different. Using four spaces consistently would be better. These values aren't names either so probably variables should be just ${list1} and ${list2}.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pekkaklarck

Copy link
Copy Markdown
Member

Yeah, this can easily be included to RF 3.2. Please take a look at the review comments. I hope you can fix them all so that I can simply merge this online without any further changes.


Lists Should Be Equal Ignore Order
${list1} = Create List A B C D
${list2} = Create List D B C A

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Somehow formatting of this shown differently but I just checked checked in file here and it
shows correct.

image

@pekkaklarck pekkaklarck Feb 28, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's probably a tab between C and A. I can fix that myself.

@bbpatel2001

Copy link
Copy Markdown
Contributor Author

Changes done @pekkaklarck

@pekkaklarck

Copy link
Copy Markdown
Member

Looks good to me. Documentation could perhaps be enhanced a bit but I can do that after merging. Thanks!

@pekkaklarck
pekkaklarck merged commit 0032b78 into robotframework:master Feb 28, 2020
@rainydew

rainydew commented Feb 28, 2020 •

Copy link
Copy Markdown

well... is that work all time?

test in python3.6.8

>>> sorted([{1,2}, {3,4}]) == sorted([{4,3}, {2,1}])
False

but since set is orderless, i expect the above can pass the compare

@pekkaklarck

Copy link
Copy Markdown
Member

That seems to be some Python oddity:

>>> sorted([{1, 2}, {3,4}])
[{1, 2}, {3, 4}]
>>> sorted([{3, 4}, {1, 2}])
[{3, 4}, {1, 2}]

My guess is that sets cannot compared. Anyway, nothing we really can do anything.

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.

5 participants