In Python, are there any libraries that mock out responses for httplib?

I'm currently using python_flickr_api to upload photos for my app: it uses httplib to perform a multipart POST request. Problem: I want to verify that the upload really is issued in an integration...

Is there an alternative to parse_qs that handles semi-colons?

TL;DR What libraries/calls are available to handle query strings containing semi-colons differently than parse_qs? >>> urlparse.parse_qs("tagged=python;ruby") >>> {'tagged': ['python']} Full...

How to assert a URL was not requested with HTTPretty

How does one go about asserting that a target URL was never requested when using HTTPretty to intercept HTTP requests in Python unit tests?

MongoClient ConnectionFailure after httpretty.enable()

Whenever I enable HTTPretty, I'm unable to make a connection with PyMongo. I know that HTTPretty alters the core socket module; is there any way around this? Code Example: import pymongo ...

Mocking Twisted web client HTTP requests using HTTPretty

As Httpretty works on the Python socket layer, even Twisted web requests should be mocked out. But i am seeing some weird behavior on using httpretty. It tries to connect to localhost somehow....

how to unit test a REST client for an unreliable server?

I'm making a Python-based REST client for a 3rd party service that's still under development. The issue is to test/verify that the client will work under ALL kinds of scenarios. Including...

How to test the payload of a POST request?

Suppose I have a method that sends a POST request with JSON data. What would be a good way to test the JSON payload? I know how to mock requests and monkey patch the response in general (I'm using...

Mock a HTTP request that times out with HTTPretty

Using the HTTPretty library for Python, I can create mock HTTP responses of choice and then pick them up i.e. with the requests library like so: import httpretty import requests # set up a...

How to execute a python test using httpretty/sure

I'm new to python tests so don't hesitate to provide any obvious information. Basically I want to do some RESTful tests using python, and found the httpretty and sure libraries which look really...

Mocking requests sent by the Selenium WebDriver in Python and having the fake responses displayed in the browser instance driven by the driver instead

I'm currently experimenting with using the Python version of Selenium WebDriver along with the Pytest testing frameworkto do automation testing of web applications. I came across a problem when...

HTTPretty test hanging on Travis

While making python-intercom Python 3 compatible, I ran into an issue on Travis. The nosetests command doesn't appear to exit when run on Python 3.4 (it behaves as expected on Python 2.7). I...

combine httpretty with pytest tmpdir

The following pytest-test uses httpretty, to mock a request. It writes the fetched data to a file: import requests import httpretty import json from os import listdir from os.path import...

Travis build timeouts even though test output reports success

My Travis build is timing out for some reason. Here is the link to the logs: https://travis-ci.org/madedotcom/atomicpuppy/builds/70202335 And my current travis yml...

scikit-bio not working after installation

I have installed scikit-bio on my mac and when I run python -m skbio.test, I get the following error: File "/macqiime/anaconda/lib/python2.7/site-packages/skbio/io/tests/test_util.py", line 17, in...

Centos 6.6, python 2.7.2 object has no attribute 'StringIO

I'm trying to run my python tests inside docker container. Here is a part of Dockerfile that installs python .2.7.2 using CentsOS 6.6: RUN cd /tmp && \ wget...

Unable to `pip install -r requirements.txt`

I'm trying to setup a Python2.7 environment on an Ubuntu server. Using requirements.txt that we get from pip freeze on the development system, running pip install -r requirements.txt on the...

Proxy to mock ec2.describe_regions() (AWS)

I'm makeing a simple proxy with Flask to mock the call describe_regions() of AWS. The Flask server has de following code: from __future__ import unicode_literals from flask import Flask from...

How to set different responses for the GET requests in Python's unit tests

I need to return different desponses depending on the GET parameters via HTTPretty: @httpretty.activate def test_multiple_requests(): httpretty.register_uri(httpretty.GET,...

python - Can't install gensim in Mac OS

When I use PyCharm to install gensim package, the installment failed. The error messages were listed below: Collecting gensim Using cached...

ImportError: cannot import name BytesIO on eclipse

I am getting the following error and am just not able to figure out why gensim cant be imported. I tried reimporting gensim again by creating virtual environment but that didnt work as well. I am...

Mysterious UnicodeDecodeError in python3 while building Docker container

I am creating a python 3 application. https://github.com/Omrigan/TED-analysis To deploy I want to use Docker with Dockerfile located in root of my Github repo (you may check it). So, when I do...

Silence exceptions that do not result in test failure in python unittest

I am writing unit tests for a python program using the unittest framework. One of the functions of the program is connecting to an external REST API using the requests library. If there is a...

orange add-ons error Orange3-Text 0.1.9

my orange version 3.3 i installed all add-ons but when i want to install Orange3-Text 0.1.9 (i have xcode and python-3.4.4-macosx10.6) An error occurred while running a subprocess Command failed:...

moto mocking sts to get account id throwing error NotImplementedError: The get_caller_identity action has not been implemented

running on moto with version '0.4.25' on python 2.7, i get the following error: NotImplementedError: The get_caller_identity action has not been implemented import boto3 from moto import mock_sns,...

How to get a request that is not the last in HttPretty?

Using the HTTPretty library for Python, I can create mock HTTP responses for my unit tests. When the code I am testing runs, instead of my request reaching the third party, the request is...

LDAP server down "Multi Stage Docker Build"

I am building a multi stage docker for my app, using an official python image "python:3.7-buster", nginx, supervisord and uwsgi. The image build is successful and i can check routes that don't use...

How to use `httpretty` to mock out request

Here's a test I've tried writing: import httpretty import requests @httpretty.activate def test(): httpretty.register_uri( httpretty.GET, "http://localhost:8000", ...