Skip to content

Commit

Permalink
make format
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Sep 12, 2024
1 parent cedda7d commit 551ed0c
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 19 deletions.
3 changes: 2 additions & 1 deletion tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
# Maybe we're running in python2.7?
from unittest import TestCase # NOQA

from cornice.errors import Errors
from pyramid import testing
from pyramid.httpexceptions import HTTPException
from webob import exc
from webob.dec import wsgify

from cornice.errors import Errors


logger = logging.getLogger("cornice")

Expand Down
3 changes: 2 additions & 1 deletion tests/test_cors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from cornice.service import Service
from pyramid import testing
from pyramid.authentication import BasicAuthAuthenticationPolicy
from pyramid.exceptions import HTTPBadRequest, NotFound
Expand All @@ -11,6 +10,8 @@
from webtest import TestApp
from zope.interface import implementer

from cornice.service import Service

from .support import CatchErrors, TestCase


Expand Down
5 changes: 3 additions & 2 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from unittest import mock

from cornice.errors import Errors
from cornice.service import Service
from pyramid import testing
from pyramid.i18n import TranslationString
from webtest import TestApp

from cornice.errors import Errors
from cornice.service import Service

from .support import CatchErrors, TestCase


Expand Down
3 changes: 2 additions & 1 deletion tests/test_imperative_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
from unittest import mock

import pytest
from cornice.resource import add_resource, add_view
from pyramid import testing
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.httpexceptions import HTTPForbidden, HTTPOk
from pyramid.security import Allow
from webtest import TestApp

from cornice.resource import add_resource, add_view

from .support import CatchErrors, TestCase, dummy_factory


Expand Down
5 changes: 3 additions & 2 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
from unittest import mock

from cornice import Service
from cornice.pyramidhook import apply_filters
from pyramid import testing
from webtest import TestApp

from cornice import Service
from cornice.pyramidhook import apply_filters

from .support import CatchErrors, TestCase


Expand Down
5 changes: 3 additions & 2 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from unittest import mock

from cornice import CorniceRenderer
from cornice.renderer import JSONError, bytes_adapter
from pyramid.interfaces import IJSONAdapter
from pyramid.renderers import JSON
from zope.interface import providedBy

from cornice import CorniceRenderer
from cornice.renderer import JSONError, bytes_adapter

from .support import TestCase


Expand Down
3 changes: 2 additions & 1 deletion tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import json
from unittest import mock

from cornice.resource import resource, view
from pyramid import testing
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
Expand All @@ -14,6 +13,8 @@
from pyramid.security import Allow
from webtest import TestApp

from cornice.resource import resource, view

from .support import CatchErrors, TestCase, dummy_factory


Expand Down
3 changes: 2 additions & 1 deletion tests/test_resource_callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import json

from cornice.resource import resource, view
from pyramid import testing
from webtest import TestApp

from cornice.resource import resource, view

from .support import CatchErrors, TestCase


Expand Down
3 changes: 2 additions & 1 deletion tests/test_resource_custom_predicates.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from cornice.resource import resource, view
from pyramid import testing
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from webtest import TestApp

from cornice.resource import resource, view

from .support import CatchErrors, TestCase


Expand Down
3 changes: 2 additions & 1 deletion tests/test_resource_traverse.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

from cornice.resource import resource, view
from pyramid import testing
from webtest import TestApp

from cornice.resource import resource, view

from .support import CatchErrors, TestCase


Expand Down
5 changes: 3 additions & 2 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
from unittest import mock

from pyramid.exceptions import ConfigurationError
from pyramid.interfaces import IRendererFactory

from cornice.resource import resource
from cornice.service import Service, _UnboundView, clear_services, decorate_view, get_services
from cornice.util import func_name
from pyramid.exceptions import ConfigurationError
from pyramid.interfaces import IRendererFactory

from .support import DummyRequest, TestCase

Expand Down
3 changes: 2 additions & 1 deletion tests/test_service_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

from cornice import Service
from pyramid import testing
from webtest import TestApp

from cornice import Service

from .support import CatchErrors, TestCase


Expand Down
6 changes: 4 additions & 2 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,16 +784,18 @@ def test_no_body_schema(self):
self.assertEqual(len(request.errors), 0)

def test_message_normalizer_no_field_names(self):
from cornice.validators._marshmallow import _message_normalizer
from marshmallow.exceptions import ValidationError

from cornice.validators._marshmallow import _message_normalizer

parsed = _message_normalizer(ValidationError("Test message"))
self.assertEqual({"_schema": ["Test message"]}, parsed)

def test_message_normalizer_field_names(self):
from cornice.validators._marshmallow import _message_normalizer
from marshmallow.exceptions import ValidationError

from cornice.validators._marshmallow import _message_normalizer

parsed = _message_normalizer(ValidationError("Test message", field_names=["test"]))
self.assertEqual({"test": ["Test message"]}, parsed)

Expand Down
4 changes: 3 additions & 1 deletion tests/validationapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
import json

from cornice import Service
from pyramid.config import Configurator
from pyramid.httpexceptions import HTTPBadRequest

from cornice import Service

from .support import CatchErrors


Expand Down Expand Up @@ -159,6 +160,7 @@ def post7(request):
drop,
null,
)

from cornice.validators import colander_body_validator, colander_validator

COLANDER = True
Expand Down

0 comments on commit 551ed0c

Please sign in to comment.