Skip to content

Fix brittle test - #14386

Open
Moist-Cat wants to merge 2 commits into
aio-libs:masterfrom
Moist-Cat:test_fix
Open

Moist-Cat wants to merge 2 commits into
aio-libs:masterfrom
Moist-Cat:test_fix

Conversation

@Moist-Cat

@Moist-Cat Moist-Cat commented Nov 15, 2026 •

Copy link
Copy Markdown

What do these changes do?

test_websocket_connection_cancellation relies on undefined behaviour from the gc. This causes random failures if calling del doesn't trigger __del__.

Are there changes in behavior for the user?

No.

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

No.

Related issue number

pr #13039

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modifications, please add yourself to
    CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep the list in alphabetical order, the file is sorted by name.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<category>.rst for example
      (14006.contrib.rst)

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

    • ensure category is one of the following:

      • 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.
      Explain high-level effects affecting the end-users, for example:

      Test runner no longer crashes when loading non-ASCII contents
      in doctest text files -- by :user:`contributor-gh-handle`.

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

    test_websocket_connection_cancellation relies on undefined behaviour
from the gc. This causes random failures if calling del doesn't trigger __del__.
@Moist-Cat
Moist-Cat requested a review from asvetlov as a code owner November 15, 2026 15:21
@agentscanapp

agentscanapp Bot commented Nov 15, 2026

Copy link
Copy Markdown

Insufficient data

Not enough activity yet to make a reliable assessment.

View full analysis →

This is an automated analysis by AgentScan

Comment thread tests/test_client_ws_functional.py Resolved
@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Low impact] This PR appears safe to merge.

Reviews (3) · Last reviewed commit: "Add news fragment and updat CONTRIBUTORS..." · Reviewed by Greptile

@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.12%. Comparing base (fe09949) to head (920a27d).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14386   +/-   ##
=======================================
  Coverage   99.12%   99.12%           
=======================================
  Files         135      135           
  Lines       53661    53661           
  Branches     2737     2737           
=======================================
+ Hits        53191    53193    +2     
+ Misses        356      355    -1     
+ Partials      114      113    -1     
Flag Coverage Δ
Autobahn 21.66% <0.00%> (ø)
CI-GHA 99.05% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.73% <100.00%> (ø)
OS-Windows 97.48% <100.00%> (-0.01%) ⬇️
OS-macOS 98.35% <100.00%> (-0.01%) ⬇️
Py-3.11 98.29% <100.00%> (ø)
Py-3.12 98.37% <100.00%> (ø)
Py-3.13 98.36% <100.00%> (-0.01%) ⬇️
Py-3.14 98.42% <100.00%> (-0.01%) ⬇️
Py-3.15 98.43% <100.00%> (-0.01%) ⬇️
Py-3.15t 98.27% <100.00%> (-0.02%) ⬇️
Py-pypy-3.12 96.96% <100.00%> (-0.01%) ⬇️
VM-macos-latest 98.35% <100.00%> (-0.01%) ⬇️
VM-ubuntu-latest 98.73% <100.00%> (ø)
VM-windows-latest 97.48% <100.00%> (-0.01%) ⬇️
cython-coverage 83.94% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@Moist-Cat
Moist-Cat requested a review from webknjaz as a code owner November 15, 2026 15:27
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Nov 15, 2026
@codspeed

codspeed Bot commented Nov 15, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 8.4%

3 warnings

⚠️ 49 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark with a significant change ran in a different software environment

Its base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the change might come from this difference rather than from the code. Open the benchmark to see what changed.

See affected benchmarks

⚡ 1 improved benchmark
✅ 101 untouched benchmarks
⏩ 83 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_ten_compressed_responses_iter_chunked_1mb[isal.isal_zlib] 184.8 ms 170.5 ms +8.4%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Moist-Cat:test_fix (920a27d) with master (fe09949)

Open in CodSpeed

Footnotes

  1. 83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@Polandia94 Polandia94 added backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot backport-3.15 Trigger automatic backporting to the 3.15 release branch by Patchback robot labels Nov 17, 2026
@Polandia94

Copy link
Copy Markdown
Contributor

Can you edit the PR description, so it folow the pull request template: https://github.com/aio-libs/aiohttp/blob/master/.github/PULL_REQUEST_TEMPLATE.md ?
Is this test failing on some github action, or locally on some configuration?

@Moist-Cat

Copy link
Copy Markdown
Author

Can you edit the PR description, so it folow the pull request template: https://github.com/aio-libs/aiohttp/blob/master/.github/PULL_REQUEST_TEMPLATE.md ?

Done.

Is this test failing on some github action, or locally on some configuration?

It was failing locally when I added a cyclic reference to the ClientResponse class in #13039. Because of the cycle, ClientResponse.__del__ didn't trigger immediately after del websocket._response. In most of my runs, __del__ was triggered much later, making a completely unrelated test fail with an Unclosed connection warning.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot backport-3.15 Trigger automatic backporting to the 3.15 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants