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

Patching implementation will not support nesting properly #27

Open
colonelpanic8 opened this issue Jan 10, 2015 · 2 comments
Open

Patching implementation will not support nesting properly #27

colonelpanic8 opened this issue Jan 10, 2015 · 2 comments

Comments

@colonelpanic8
Copy link

It seems like cassette's patcher implementation (https://github.com/uber/cassette/blob/master/cassette/patcher.py) was lifted directly from the old version of vcr.py https://github.com/kevin1024/vcrpy/blob/master/vcr/patch.py.

There are actually some pretty nasty, though subtle and not often encountered bugs with this technique that vcr.py has since fixed.
see
kevin1024/vcrpy#107
kevin1024/vcrpy#109

None of this is urgent, but I just thought I'd mention it here in case it ever came up in cassette

@charlax
Copy link
Contributor

charlax commented Jan 10, 2015

Hey thanks for reporting this - will have look.

@adamchainz
Copy link

I think I just got one of these patching errors. I just upgraded requests from 2.4.0 to 2.5.1, and cassette from 0.3.2 to 0.3.6. This triggered errors related to cassette objects outside of tests that were using cassette, but which get run after tests that do use cassette. Everything should have been patched back, but it appears not:

  File "/opt/yplan/venv/local/lib/python2.7/site-packages/mailsnake/mailsnake.py", line 131, in get
    return self.call(method_name.replace('_', '-'), params)
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/mailsnake/mailsnake.py", line 101, in call
    req = requests.post(url, data=data, headers=headers)
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/api.py", line 99, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/api.py", line 49, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 461, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/adapters.py", line 370, in send
    timeout=timeout
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 518, in urlopen
    body=body, headers=headers)
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 322, in _make_request
    self._validate_conn(conn)
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 727, in _validate_conn
    conn.connect()
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connection.py", line 204, in connect
    conn = self._new_conn()
  File "/opt/yplan/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connection.py", line 129, in _new_conn
    if self.socket_options:
AttributeError: 'UL3CassetteHTTPSConnection' object has no attribute 'socket_options'
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: INFO: Starting new HTTPS connection (1): mandrillapp.com
--------------------- >> end captured logging << ---------------------

Reverting cassette to 0.3.2 solved these errors.

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

No branches or pull requests

3 participants