Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
papaeye committed Jun 13, 2013
0 parents commit e3f56c3
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.egg-info
*.pyc

/.tox
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.md
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# pytest-httpretty - A thin wrapper of HTTPretty for pytest

```python
import requests

def test_httpretty(httpretty):
httpretty.register_uri(httpretty.GET, 'http://example.com/', body='Hello')
assert requests.get('http://example.com').text == 'Hello'

def test_stub_get(stub_get):
stub_get('http://example.com/', body='World!')
assert requests.get('http://example.com').text == 'World!'
```
21 changes: 21 additions & 0 deletions pytest_httpretty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import httpretty as _httpretty
import pytest


__version__ = '0.1.dev'


@pytest.fixture
def httpretty(request):
_httpretty.httpretty.reset()
_httpretty.httpretty.enable()
request.addfinalizer(_httpretty.httpretty.disable)
return _httpretty


@pytest.fixture
def stub_get(request, httpretty):
def wrapper(*args, **kwargs):
httpretty.register_uri(httpretty.GET, *args, **kwargs)
return httpretty
return wrapper
48 changes: 48 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os.path
import re

from setuptools import setup


def read(filename):
path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
filename)
return open(path).read()


__version__ = re.search("^__version__ = '(.+)'",
read('pytest_httpretty.py'), re.M).group(1)


setup(name='pytest-httpretty',
version=__version__,
description='A thin wrapper of HTTPretty for pytest',
author='papaeye',
author_email='[email protected]',
url='http://github.com/papaeye/pytest-httpretty',
py_modules=['pytest_httpretty'],
include_package_data=True,
install_requires=[
'httpretty',
'pytest',
],
tests_require=[
'requests'
],
zip_safe=False,
keywords='pytest httpretty http stub mock',
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
],
platforms='any',
license='BSD License',
entry_points={
'pytest11': ['httpretty = pytest_httpretty']
})
13 changes: 13 additions & 0 deletions test_pytest_httpretty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import requests


def test_httpretty(httpretty):
httpretty.register_uri(httpretty.GET, 'http://example.com/', body='Hello')

assert requests.get('http://example.com').text == 'Hello'


def test_stub_get(stub_get):
stub_get('http://example.com/', body='World!')

assert requests.get('http://example.com').text == 'World!'
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tox]
envlist = py27, py33

[testenv]
deps =
httpretty
pytest
requests
commands = py.test

0 comments on commit e3f56c3

Please sign in to comment.