GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-61215: threadingmock: Improve test suite to avoid race conditions by mariocj89 · Pull Request #106822 · python/cpython

Conversation

@mariocj89

@mariocj89 mariocj89 commented Jul 17, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Simplify tests and split them into multiple tests to prevent assertions from triggering race conditions.
Additionally, we rely on calling the mocks without delay to validate the functionality of matching calls.
The test suite had a lot of duplicated validation and tests that valdated multiple potentially racing calls that made it flaky.

The test suite has been changed to use single very short timeout that we wait on, so the only race that can happen is for the method to be called before we call "wait_until_X". Should that happen the test suite succeeds any way (as expected).

The change also runs the suite significantly faster (40% in my laptop).

@cjw296 let me know if you think I'm missing anything from testing but I think this does covers the whole functionality.

  • Issue: Allow waiting on a mock #61215

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mariocj89
threadingmock: Improve test suite to avoid race conditions
9937486
Simplify tests and split them into multiple tests to prevent assertions
from triggering race conditions.
Additionally, we rely on calling the mocks without delay to validate the
functionality of matching calls.
@mariocj89
mariocj89 requested a review from cjw296 as a code owner July 17, 2023 12:18
@bedevere-bot bedevere-bot added the awaiting review label Jul 17, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jul 17, 2023
Allow waiting on a mock #61215
Closed
@mariocj89 mariocj89 mentioned this pull request Jul 17, 2023
gh-61215: New mock to wait for multi-threaded events to happen #16094
Merged
@cjw296 cjw296 added skip issue skip news labels Jul 17, 2023
cjw296
cjw296 approved these changes Jul 17, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Jul 17, 2023
@cjw296
cjw296 enabled auto-merge (squash) July 17, 2023 18:56
@cjw296
cjw296 merged commit 7e96370 into python:main Jul 17, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cjw296 cjw296 cjw296 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mariocj89 @cjw296 @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.