Skip to content

Commit bf816f6

Browse files
author
Dan Root
committed
Add more packaging.
Tox test wrapper, coveragerc, etc.
1 parent 7a0852a commit bf816f6

File tree

9 files changed

+107
-10
lines changed

9 files changed

+107
-10
lines changed

.coveragerc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[run]
2+
branch = True
3+
source = flask_jsonwrap
4+
omit =
5+
*/test/*
6+
.tox/*
7+
8+
[report]
9+
exclude_lines =
10+
✘${TOX_ENVNAME}
11+
pragma: no ?cover

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.cache
22
*.egg*
3+
.tox
4+
.coverage
5+
.python-version

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include README.md

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Flask-JSONWrap
2+
==============
3+
4+
A Flask extension for wrapping errors in appropriate JSON-API compatible json.
5+
6+
7+
Installation
8+
------------
9+
10+
Install the extension using pip:
11+
12+
$ pip install -U flask-jsonwrap
13+
14+
15+
Usage
16+
-----
17+
18+
19+
This package exposes a Flask exentions which overwrites the default HTML error
20+
handling endpoints in Flask with endpoints that return error messages in the
21+
manner decribed by [JSON-API](http://jsonapi.org)
22+
23+
24+
```python
25+
from flask_jsonwrap import JSONWrap
26+
27+
app = Flask(__name__)
28+
jsonwrap = JSONWrap()
29+
jsonwrap.init_app(app)
30+
```
31+
32+
33+
Tests
34+
-----
35+

flask_jsonwrap/jsonwrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def make_json_error(self, ex):
3131
return response
3232

3333
def init_app(self, app):
34-
for code in default_exceptions.iterkeys():
34+
for code in default_exceptions.keys():
3535
app.register_error_handler(code, self.make_json_error)
3636

3737
return app

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ norecursedirs =
1111
tmp
1212
ve
1313
.eggs
14+
.tox
1415

1516
flake8-ignore =
1617
test/** ALL

setup.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,59 @@
66
"""
77
from setuptools import setup, find_packages
88

9+
requires = {
10+
'setup': [
11+
],
12+
'install': [
13+
'Flask',
14+
'simplejson',
15+
],
16+
'tests': [
17+
'pytest',
18+
'pytest-cov',
19+
'pytest-flake8',
20+
'requests',
21+
],
22+
}
23+
24+
requires['all'] = list({dep for deps in requires.values() for dep in deps})
25+
26+
27+
def readme():
28+
with open('README.md', 'r') as f:
29+
return f.read()
930

1031
setup(
1132
name='Flask-JSONWrap',
1233
description='Make a Flask app JSON API friendly.',
13-
long_description=__doc__,
34+
long_description=readme(),
1435
url='http://github.com/daroot/flask-jsonwrap/',
1536
version='1.0.1',
1637
author='Dan Root',
17-
author_email='rootdan@gmail.com',
38+
author_email='rootdan+pypi@gmail.com',
1839
license='WTFPL',
1940

2041
packages=find_packages(exclude=['doc', 'test']),
21-
setup_requires=['pytest-runner'],
22-
install_requires=[
23-
'Flask',
24-
],
25-
tests_require=['pytest'],
42+
setup_requires=requires['setup'],
43+
install_requires=requires['install'],
44+
tests_require=requires['tests'],
2645
zip_safe=False,
2746
include_package_data=True,
2847

2948
platforms='any',
3049

3150
keywords=['flask', 'jsonapi'],
3251
classifiers=[
52+
'Development Status :: 4 - Beta',
3353
'Environment :: Web Environment',
3454
'Intended Audience :: Developers',
3555
'License :: Freely Distributable',
3656
'Operating System :: OS Independent',
3757
'Programming Language :: Python',
58+
'Programming Language :: Python :: 2.7',
59+
'Programming Language :: Python :: 3.3',
60+
'Programming Language :: Python :: 3.4',
61+
'Programming Language :: Python :: 3.5',
3862
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
3963
'Topic :: Software Development :: Libraries :: Python Modules',
4064
]

test/test_json_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ def test_wrapped_responses(wrapped_client, unwrapped_client, path, code,
5858
wrapped = wrapped_client.get(path)
5959

6060
assert unwrapped.status_code == code
61-
assert expected_unwrapped in unwrapped.data
61+
assert expected_unwrapped in unwrapped.data.decode()
6262
assert wrapped.status_code == code
63-
assert expected_wrapped == json.loads(wrapped.data)
63+
assert expected_wrapped == json.loads(wrapped.data.decode())

tox.ini

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[tox]
2+
envlist = py27, py33, py34, py35, pypy, flake8
3+
4+
[testenv]
5+
setenv =
6+
TOX_ENVNAME = {envname}
7+
PYTHONDONTWRITEBYTECODE = VERYYES
8+
deps =
9+
pytest
10+
pytest-cov
11+
pytest-flake8
12+
requests
13+
.
14+
15+
commands =
16+
coverage run -m py.test
17+
18+
[testenv:flake8]
19+
basepython=python
20+
deps=flake8
21+
commands=
22+
flake8 flask_jsonwrap

0 commit comments

Comments
 (0)