Skip to content

Refactor/replace httpretty with responses#577

Merged
jdepoix merged 2 commits intojdepoix:masterfrom
kaya70875:refactor/replace-httpretty-with-responses
Mar 9, 2026
Merged

Refactor/replace httpretty with responses#577
jdepoix merged 2 commits intojdepoix:masterfrom
kaya70875:refactor/replace-httpretty-with-responses

Conversation

@kaya70875
Copy link
Copy Markdown
Contributor

@kaya70875 kaya70875 commented Mar 7, 2026

This PR migrates the test suite's HTTP mocking library from httpretty (which is no langer actively maintained) to responses to provide better stability and integration with the requests library. The existing unittest.TestCase architecture was preserved to keep the refactor focused and the diff clean.

Key Changes

  • Mock Lifecycle: Replaced httpretty.activate with responses.start() and self.addCleanup(responses.stop) inside setUp() to ensure base mocks persist correctly across the test lifecycle.

  • State Overrides: Used responses.replace() and chained responses.add() calls to handle test-specific mock overrides and sequential retry logic (e.g., for proxy and consent cookie tests).

  • Content-Type Fixes: Explicitly added content_type="application/json" to innertube API mocks. responses defaults to text/plain, which was preventing the error handler from parsing JSON and causing false-positive VideoUnplayable exceptions.

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 22795606950

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 21472046532: 0.0%
Covered Lines: 505
Relevant Lines: 505

💛 - Coveralls

@jdepoix
Copy link
Copy Markdown
Owner

jdepoix commented Mar 9, 2026

Thank you for your contribution @kaya70875 🙏

@jdepoix jdepoix merged commit a6352e9 into jdepoix:master Mar 9, 2026
11 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.

3 participants