vcrpy: vcrpy doesn't work under django?

I’m trying to use vcrpy to accelerate the execution of my django application test suite. I’m using django 1.7 on Mac, with Python 2.7.

I added the following couple of lines to one of my tests:

     import vcr
     with vcr.use_cassette('recording.yaml'):

The result is an import error:

    import vcr
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/__init__.py", line 2, in <module>
    from .config import VCR
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/config.py", line 6, in <module>
    from .cassette import Cassette
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/cassette.py", line 12, in <module>
    from .patch import CassettePatcherBuilder
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/patch.py", line 8, in <module>
    from .stubs import VCRHTTPConnection, VCRHTTPSConnection
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/stubs/__init__.py", line 9, in <module>
    from six.moves.http_client import (
ImportError: No module named http_client

The problematic code in stubs/init.py is :

import six
from six.moves.http_client import (
    HTTPConnection,
    HTTPSConnection,
    HTTPMessage,
    HTTPResponse,
)

This code seems to run fine when I’m just running it from a plain python console, but it results in the above ImportError under django.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 34 (5 by maintainers)

Most upvoted comments

Closing bc no one seems to have this issue anymore.