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.

vcrpy doesn't work under django?

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:34 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
IvanMalisoncommented, Jul 2, 2019

Closing bc no one seems to have this issue anymore.

0reactions
brechincommented, Oct 19, 2016

FWIW, I’m using vcrpy 1.10.2 to help in testing an application built with Django 1.9.6 and Django Rest Framework 3.3.3 with no issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features — vcrpy 4.2.1 documentation
Advanced Features¶. If you want, VCR.py can return information about the cassette it is using to record your requests and responses.
Read more >
vcrpy record cassettes doesn't record in a test using test_client ...
But when I run the test the cassette was not generated. The thing is that if I change client.post by requests.post the response...
Read more >
Lessons learned building with Django, Celery, and Pytest
As someone who writes ruby professionally, I recently learned python to build a bot which buys an index of crypto using binance.
Read more >
How Hypothesis and VCR Changed the Way I Do Testing in ...
Jethro Muller is a software developer at Flickswitch. He primarily works in Python with Django on server-side code. He enjoys ORM query ...
Read more >
Testing Django on Steroids with Pytest - Mad Devs
You do not waste your time to run manual tests;; Design of your code becomes better;; You prove with a working test that...
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