G
G
geocoder2012-09-16 14:12:43
Python
geocoder, 2012-09-16 14:12:43

Fake HTTP server for tests in Python?

Hello.

Please advise some solution for testing httplib/urllib2-dependent code.
There is a simple class that sends requests to the server, you need to emulate this server.

Don't want to do monkeypatching on httplib, urllib2.

Thank you.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
mr_idiot, 2012-09-16
@gecoder

Why do you call the test server "fake"? Take any microframework (for example, flask) and write yourself any api.

M
marazmiki, 2012-09-16
@marazmiki

It is still customary to do such things through Mock objects.

A
avalak, 2012-09-16
@avalak

I did not quite understand what you need, but here is the server (for statics) in python

python -m SimpleHTTPServer 8080

G
gecoder, 2012-09-16
@gecoder

Thanks for answers.
In general, I did just that, I took the Bottle.py microframework right in the code, I run it in a separate daemon thread. And at the end I cut it down, it works with a bang.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question