Skip to content
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

PYTHON-4763 Migrate test_change_stream.py to async #1853

Merged
merged 30 commits into from
Sep 16, 2024

Conversation

sleepyStick
Copy link
Contributor

No description provided.

@sleepyStick sleepyStick marked this pull request as ready for review September 12, 2024 02:13
Copy link
Contributor

@NoahStapp NoahStapp left a comment

Choose a reason for hiding this comment

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

The async test_change_stream.py file is missing?

@@ -310,7 +312,7 @@ def _test_next_blocks(self, change_stream):
@no_type_check
def test_next_blocks(self):
"""Test that next blocks until a change is readable"""
# Use a short await time to speed up the test.
# Use a short time to speed up the test.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Use a short time to speed up the test.
# Use a short wait time to speed up the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed :)

@@ -325,7 +327,7 @@ def test_aggregate_cursor_blocks(self):
@no_type_check
def test_concurrent_close(self):
"""Ensure a ChangeStream can be closed from another thread."""
# Use a short await time to speed up the test.
# Use a short time to speed up the test.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Use a short time to speed up the test.
# Use a short wait time to speed up the test.

Copy link
Contributor

@NoahStapp NoahStapp left a comment

Choose a reason for hiding this comment

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

The async test_change_stream.py file is missing?

@sleepyStick
Copy link
Contributor Author

The async test_change_stream.py file is missing?

omg one sec, i always forget that -a doesn't add the file... ;-;

@sleepyStick sleepyStick marked this pull request as draft September 12, 2024 17:03
@sleepyStick
Copy link
Contributor Author

like fifty attempts later, its ready HAHA

@sleepyStick sleepyStick marked this pull request as ready for review September 13, 2024 22:13
Copy link
Contributor

@NoahStapp NoahStapp left a comment

Choose a reason for hiding this comment

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

A few minor comments, otherwise looks great!

@@ -158,10 +162,14 @@ def test_try_next(self):
with self.change_stream(max_await_time_ms=250) as stream:
self.assertIsNone(stream.try_next()) # No changes initially.
coll.insert_one({}) # Generate a change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unneeded added space here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah...I'll try again for sure, but i tried to delete it and when i ran pre-commit it was added again??? not sure why though

Copy link
Member

Choose a reason for hiding this comment

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

Because the async file overwrites the sync one

Copy link
Member

Choose a reason for hiding this comment

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

ohh, I think it is because ruff is just doing that because the file has changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah so I found the space in the async file, deleted it, and then it got added back during pre-commit

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah in that case never mind, if the formatter adds an extra space that's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

perfect, because I just gave up on trying to convince it otherwise

wait_until(lambda: stream.try_next() is not None, "get change from try_next")

def _wait_until():
return stream.try_next()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return stream.try_next()
return stream.try_next() is not None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed :)

wait_until(lambda: stream.try_next() is not None, "get change from try_next")

def _wait_until():
return stream.try_next()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return stream.try_next()
return stream.try_next() is not None

@sleepyStick sleepyStick merged commit 0c0633d into mongodb:master Sep 16, 2024
33 of 34 checks passed
@sleepyStick sleepyStick deleted the PYTHON-4763 branch September 16, 2024 17:21
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