Skip to content

Simplify failure deduplication in looponfail#544

Open
lgeiger wants to merge 1 commit into
pytest-dev:masterfrom
lgeiger:simplify-deduplication
Open

Simplify failure deduplication in looponfail#544
lgeiger wants to merge 1 commit into
pytest-dev:masterfrom
lgeiger:simplify-deduplication

Conversation

@lgeiger

@lgeiger lgeiger commented Jun 20, 2020

Copy link
Copy Markdown
Contributor

This PR simplifies deduplication of failures in looponfail using set instead of iterating over all failures. This should simplify the code and in general might be a bit faster as well.

@RonnyPfannschmidt RonnyPfannschmidt left a comment

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.

i finally got to this

it looks good, it took a bit to follow back how it goes into the remotes trails variable

please rebase to master and add a changelog entry (or let me know if i may do that for you)

nice find!

@lgeiger lgeiger force-pushed the simplify-deduplication branch from e8f7d61 to f51cd65 Compare March 30, 2022 23:39
@lgeiger

lgeiger commented Mar 30, 2022

Copy link
Copy Markdown
Contributor Author

Sorry for the late reply, I somehow missed the review. I rebased onto master, let's see what CI thinks.

Comment thread src/xdist/looponfail.py
if failure not in uniq_failures:
uniq_failures.append(failure)
self.failures = uniq_failures
self.failures = list(set(failures))

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.

does this preserve order?

@lgeiger lgeiger Mar 31, 2022

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.

It does not, I can change it to

Suggested change
self.failures = list(set(failures))
self.failures = list(dict.fromkeys(failures))

which will preserve the order if required.

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.

2 participants