Skip to content

test: fix flaky live-API tests, restore pytest-retry - #975

Merged
sigma67 merged 3 commits into
mainfrom
fix-upload-test-retries
Aug 8, 2026
Merged

test: fix flaky live-API tests, restore pytest-retry#975
sigma67 merged 3 commits into
mainfrom
fix-upload-test-retries

Conversation

@sigma67

@sigma67 sigma67 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • --retries was accidentally set to 0 in default search: fix itemSection parsing #939 (unrelated PR, no discussion) and never restored — this removed the safety net for flaky live-account tests, e.g. the upload test failure on main caused by the newly added -n 2 xdist parallelism increasing load on the shared test account: https://github.com/sigma67/ytmusicapi/actions/runs/30170681258/job/89711551512
  • Restores --retries 2 (its original value from drop 3.8, add pytest-retry #592)
  • Drops the manual polling loop in test_upload_song_and_verify now that pytest-retry re-runs the whole test on failure
  • Fixes a real parsing bug found while investigating other flaky failures (https://github.com/sigma67/ytmusicapi/actions/runs/31191983233/job/92910797267): when searching with a type filter (e.g. featured_playlists), YTM sometimes pads results with an unrelated shelf (e.g. a "Songs" category). search() forced every shelf's items to the requested filter's type regardless of the shelf's actual category, corrupting resultType/itemCount/author for those items. Now shelves whose category doesn't match the requested filter are skipped instead of mislabeled.
  • test_many_episodes now tolerates 404s from get_episode(): episode search can surface episodes YTM has since removed/delisted, and that's not a bug worth failing the test over.

Test plan

  • CI passes on this PR

--retries was accidentally zeroed out in #939 and never restored, removing
the safety net for flaky live-account tests like the upload/parallel-xdist
timeout seen on main. Also drops the now-redundant manual retry loop in
test_upload_song_and_verify in favor of pytest-retry re-running the test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sigma67 sigma67 self-assigned this Aug 8, 2026
YTM sometimes pads filtered results (e.g. featured_playlists) with an
unrelated shelf (e.g. "Songs"). The parser forced every shelf's items
to the requested filter's type regardless of the shelf's actual
category, corrupting resultType/itemCount/author for those items.
Skip shelves whose category doesn't match the requested filter.
Episode search results can surface episodes that YTM has since
removed/delisted, causing a 404 on the get_episode follow-up call.
Skip those instead of failing the whole test.
@sigma67 sigma67 changed the title test: re-enable pytest-retry, simplify upload verify test test: fix flaky live-API tests, restore pytest-retry Aug 8, 2026
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.77%. Comparing base (368d774) to head (e991ec2).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #975      +/-   ##
==========================================
- Coverage   95.78%   95.77%   -0.02%     
==========================================
  Files          47       47              
  Lines        2707     2723      +16     
==========================================
+ Hits         2593     2608      +15     
- Misses        114      115       +1     
Flag Coverage Δ
unittests 95.77% <100.00%> (-0.02%) ⬇️

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.

@sigma67
sigma67 merged commit 72d47b3 into main Aug 8, 2026
8 checks passed
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.

1 participant