-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e3f56c3
Showing
7 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.egg-info | ||
*.pyc | ||
|
||
/.tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |