question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cookie handling regression from 0.14.0 to 0.15.0

See original GitHub issue

Environment

Using the responses library under Python 3.9.7

Steps to Reproduce

Run this test against responses 0.14.0 and against responses 0.15.0

#!/usr/bin/env python3
import sys
import requests
import responses



def main():
    with responses.RequestsMock() as fakes:
        fakes.add(responses.GET, 'https://example.com', status=200,
            adding_headers=[
                  ('Set-Cookie', 'mycookie=myvalue; path=/; secure'),
            ],
        body="Returned body",
        )

        session = requests.session()
        response = session.get('https://example.com')

        tests = {}
        tests['response-cookie'] = 'mycookie' in response.cookies
        tests['session-cookie'] = 'mycookie' in session.cookies

        failures = 0
        for testname, result in tests.items():
            if not result:
                failures += 1
            sys.stdout.write(f"Test {testname} result {result}\n")
        if failures:
            sys.stdout.write(f"{failures} of {len(tests)} failed.\n")
        else:
            sys.stdout.write(f"All {len(tests)} tests passed.\n")

        return 1 if failures else 0

if __name__ == '__main__':
    sys.exit(main())

Expected Result

Expected ‘mycookie’ to appear in both the response.cookies and the session.cookies

Actual Result

‘mycookie’ appears in both the response.cookies and the session.cookies for 0.14.0 ‘mycookie’ appears in the response.cookies but not in the session.cookies for 0.15.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:25 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
markstorycommented, Nov 11, 2021
1reaction
retracilecommented, Oct 27, 2021

I suspect the issue may be the removal of the response.close() call in RequestsMock._on_request, but I’m not sure.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog - encode/httpx - GitHub
Regression in 0.21.2. ... 0.15.0 (September 22nd, 2020) ... Handling multiple Set-Cookie headers became broken in the 0.14.0 release, ...
Read more >
Release Notes - Kolibri developer documentation
This release fixes a regression with quiz display for non-admins. Fixed¶. Clean up state management for user management page in https://github.com/ ...
Read more >
Effect Size in Statistics - The Ultimate Guide - SPSS tutorials
Quick guide to which effect size you must use for which test and how to get it. Includes rules of thumb for small,...
Read more >
Release Notes - Starlette
0.15.0. June 23, 2021. This release includes major changes to the low-level asynchronous parts of Starlette. As a result, Starlette now depends on...
Read more >
Changelog | Data Flow Graph | 0.15.0-preview.5
[0.15.0-preview.4] - 2020-06-10. Fixed. Fix regression where post-processing would crash on NodeDefinition 's who's INodeData , ISimulationPortDefinition ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found