Skip to content

Commit

Permalink
Merge pull request #246 from sloria/warnings
Browse files Browse the repository at this point in the history
Address a few warnings and bump required marshmallow version
  • Loading branch information
sloria committed Jul 10, 2018
2 parents 30988aa + 50d9048 commit 15b6a25
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cache: pip

env:
# Lowest supported version
- MARSHMALLOW_VERSION="==2.7.0"
- MARSHMALLOW_VERSION="==2.15.0"
# Latest release
- MARSHMALLOW_VERSION=""

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Other changes:

* *Backwards-incompatible*: Drop support for Python 3.4 (:issue:`243`). Python 2.7 and
>=3.5 are supported.
* *Backwards-incompatible*: Drop support for marshmallow<2.15.0.
marshmallow>=2.15.0 and >=3.0.0b12 are officially supported.
* Use `black <https://github.com/ambv/black>`_ with `pre-commit <https://pre-commit.com/>`_
for code formatting.

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[wheel]
[bdist_wheel]
universal = 1

[flake8]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

# Requirements
REQUIREMENTS = ["marshmallow>=2.7.0"]
REQUIREMENTS = ["marshmallow>=2.15.0"]


def find_version(fname):
Expand Down
8 changes: 6 additions & 2 deletions tests/apps/aiohttp_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
class HelloSchema(ma.Schema):
name = fields.Str(missing="World", validate=lambda n: len(n) >= 3)

if MARSHMALLOW_VERSION_INFO[0] < 3:

class Meta:
strict = True


strict_kwargs = {"strict": True} if MARSHMALLOW_VERSION_INFO[0] < 3 else {}
hello_many_schema = HelloSchema(many=True, **strict_kwargs)
Expand Down Expand Up @@ -140,9 +145,8 @@ async def echo_match_info(request):


class EchoHandler:
@asyncio.coroutine
@use_args(hello_args)
def get(self, request, args):
async def get(self, request, args):
return json_response(args)


Expand Down
10 changes: 9 additions & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ def create_app(self):
def create_testapp(self, app):
return webtest.TestApp(app)

def before_create_app(self):
pass

def after_create_app(self):
pass

@pytest.fixture(scope="class")
def testapp(self):
return self.create_testapp(self.create_app())
self.before_create_app()
yield self.create_testapp(self.create_app())
self.after_create_app()

def test_parse_querystring_args(self, testapp):
assert testapp.get("/echo?name=Fred").json == {"name": "Fred"}
Expand Down
4 changes: 4 additions & 0 deletions tests/test_aiohttpparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ def create_app(self):

def create_testapp(self, app):
loop = asyncio.get_event_loop()
self.loop = loop
return webtest_aiohttp.TestApp(app, loop=loop)

def after_create_app(self):
self.loop.close()

@pytest.mark.skip(reason="files location not supported for aiohttpparser")
def test_parse_files(self, testapp):
pass
Expand Down
15 changes: 14 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,11 @@ def test_parse_with_callable(web_request, parser):
class MySchema(Schema):
foo = fields.Field()

if MARSHMALLOW_VERSION_INFO[0] < 3:

class Meta:
strict = True

def make_schema(req):
assert req is web_request
return MySchema(context={"request": req})
Expand All @@ -662,7 +667,7 @@ class HelloSchema(Schema):

if MARSHMALLOW_VERSION_INFO[0] < 3:

class Meta(object):
class Meta:
strict = True

@post_load
Expand All @@ -689,6 +694,10 @@ class UserSchema(Schema):
id = fields.Int(dump_only=True)
email = fields.Email()
password = fields.Str(load_only=True)
if MARSHMALLOW_VERSION_INFO[0] < 3:

class Meta:
strict = True

def test_passing_schema_to_parse(self, parser, web_request):
web_request.json = {"id": 12, "email": "foo@bar.com", "password": "bar"}
Expand Down Expand Up @@ -793,6 +802,10 @@ def test_parse_does_not_add_missing_values_to_schema_validator(
class UserSchema(Schema):
name = fields.Str()
location = fields.Field(required=False)
if MARSHMALLOW_VERSION_INFO[0] < 3:

class Meta:
strict = True

@validates_schema(pass_original=True)
def validate_schema(self, data, original_data):
Expand Down

0 comments on commit 15b6a25

Please sign in to comment.