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

Replaced usage of 'aiohttp.testutils.make_mocked_coro' to 'mock.AsyncMock()' (PR #1 to fix issue #9212) #9357

Closed
wants to merge 4 commits into from

Conversation

TheMarvelFan
Copy link

PR number 1 to fix issue #9212

What do these changes do?

The usage of 'aiohttp.testutils.make_mocked_coro' was replaced with 'mock.AsyncMock()' in several files, but I left the original method declaration intact so the code doesn't break.

Are there changes in behavior for the user?

No

Is it a substantial burden for the maintainers to support this?

Related issue number

Fixes issue #9212 (in part)

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<type>.rst (e.g. 588.bugfix.rst)

    • if you don't have an issue number, change it to the pull request
      number after creating the PR

      • .bugfix: A bug fix for something the maintainers deemed an
        improper undesired behavior that got corrected to match
        pre-agreed expectations.
      • .feature: A new behavior, public APIs. That sort of stuff.
      • .deprecation: A declaration of future API removals and breaking
        changes in behavior.
      • .breaking: When something public is removed in a breaking way.
        Could be deprecated in an earlier release.
      • .doc: Notable updates to the documentation structure or build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and tooling. Changes in the test invocation considerations and
        runtime assumptions.
      • .contrib: Stuff that affects the contributor experience. e.g.
        Running tests, building the docs, setting up the development
        environment.
      • .misc: Changes that are hard to assign to any of the above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:

      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.

      Use the past tense or the present tense a non-imperative mood,
      referring to what's changed compared to the last released version
      of this project.

tests/test_client_ws.py Fixed Show fixed Hide fixed
@@ -673,10 +673,10 @@ def make_mocked_request(

if writer is None:
writer = mock.Mock()
Copy link
Member

@Dreamsorcerer Dreamsorcerer Sep 30, 2024

Choose a reason for hiding this comment

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

Ideally, this would be replaced with mock.create_autospec().
If that's too much to figure out, then I think AsyncMock should atleast be using return_value=None. I don't think you should be passing any positional arguments to it.

Copy link
Member

@Dreamsorcerer Dreamsorcerer left a comment

Choose a reason for hiding this comment

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

At a minimum, I think all the AsyncMocks with positional arguments need to be changed to use return_value.
Though it would be nice to see some more autospecs in the code (but, I guess it's not a strict requirement for this task).

And then the failing tests need to be debugged if they are not fixed by that change.

@TheMarvelFan
Copy link
Author

Hi @Dreamsorcerer ,
It looks like I am going to be busy this month, due to my approaching midterm exams. So, I would not be able to follow through with this issue.
Besides this, I also got 4 PRs merged for Hacktoberfest, so I want to leave this issue open for someone else who wants to participate.
Hope this is understandable.

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