diff options
| author | Michael Merickel <michael@merickel.org> | 2018-10-15 02:42:09 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2018-10-15 09:24:07 -0500 |
| commit | 10ddb6f08592c2740b966e98a6f98a5b83af1896 (patch) | |
| tree | 2e90443b3d8503ac722aa22f52f18f5108498560 /tests | |
| parent | 4d838f06d0e6d27e34b766fc5c34a8283ff31b38 (diff) | |
| download | pyramid-10ddb6f08592c2740b966e98a6f98a5b83af1896.tar.gz pyramid-10ddb6f08592c2740b966e98a6f98a5b83af1896.tar.bz2 pyramid-10ddb6f08592c2740b966e98a6f98a5b83af1896.zip | |
fix lint on tests
Diffstat (limited to 'tests')
34 files changed, 239 insertions, 280 deletions
diff --git a/tests/pkgs/conflictapp/included.py b/tests/pkgs/conflictapp/included.py index 5f483ff81..fc42c317e 100644 --- a/tests/pkgs/conflictapp/included.py +++ b/tests/pkgs/conflictapp/included.py @@ -1,7 +1,7 @@ from webob import Response -def bview(request): +def bview(request): # pragma: no cover return Response('b view') diff --git a/tests/test_compat.py b/tests/test_compat.py index 46fc7d944..4a14caedf 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -16,17 +16,17 @@ class TestUnboundMethods(unittest.TestCase): self.assertTrue(is_unbound_method(NewStyle.run)) def test_normal_func_unbound(self): - def func(): + def func(): # pragma: no cover return 'OK' self.assertFalse(is_unbound_method(func)) class OldStyle: - def run(self): + def run(self): # pragma: no cover return 'OK' class NewStyle(object): - def run(self): + def run(self): # pragma: no cover return 'OK' diff --git a/tests/test_config/__init__.py b/tests/test_config/__init__.py index 315e8c939..ac1f19667 100644 --- a/tests/test_config/__init__.py +++ b/tests/test_config/__init__.py @@ -1,5 +1,5 @@ # package - +from functools import partial from zope.interface import implementer from zope.interface import Interface @@ -8,11 +8,11 @@ class IFactory(Interface): pass -def dummy_tween_factory(handler, registry): +def dummy_tween_factory(handler, registry): # pragma: no cover pass -def dummy_tween_factory2(handler, registry): +def dummy_tween_factory2(handler, registry): # pragma: no cover pass @@ -59,8 +59,6 @@ def dummy_extend2(config, discrim): config.action(discrim, None, config.registry) -from functools import partial - dummy_partial = partial(dummy_extend, discrim='partial') diff --git a/tests/test_config/test_adapters.py b/tests/test_config/test_adapters.py index 6237995d0..d871e8825 100644 --- a/tests/test_config/test_adapters.py +++ b/tests/test_config/test_adapters.py @@ -177,7 +177,7 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase): L = [] - def subscriber(event): + def subscriber(event): # pragma: no cover L.append(event) config = self._makeOne(autocommit=True) @@ -206,7 +206,7 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase): L = [] - def subscriber(event): + def subscriber(event): # pragma: no cover L.append(event) config = self._makeOne(autocommit=True) @@ -394,7 +394,7 @@ class Test_eventonly(unittest.TestCase): return eventonly(callee) def test_defaults(self): - def acallable(event, a=1, b=2): + def acallable(event, a=1, b=2): # pragma: no cover pass self.assertTrue(self._callFUT(acallable)) diff --git a/tests/test_config/test_factories.py b/tests/test_config/test_factories.py index 325ba52f3..c03d3f68b 100644 --- a/tests/test_config/test_factories.py +++ b/tests/test_config/test_factories.py @@ -114,7 +114,7 @@ class TestFactoriesMixin(unittest.TestCase): config = self._makeOne(autocommit=True) - def foo(self): + def foo(self): # pragma: no cover pass config.add_request_method(foo) @@ -126,10 +126,10 @@ class TestFactoriesMixin(unittest.TestCase): config = self._makeOne() - def foo(self): + def foo(self): # pragma: no cover pass - def bar(self): + def bar(self): # pragma: no cover pass config.add_request_method(foo, name='bar') @@ -149,7 +149,7 @@ class TestFactoriesMixin(unittest.TestCase): config = self._makeOne() - def bar(self): + def bar(self): # pragma: no cover pass config.add_request_method(name='foo') @@ -161,13 +161,12 @@ class TestFactoriesMixin(unittest.TestCase): self.assertRaises(AttributeError, config.add_request_method) def test_add_request_method_with_text_type_name(self): - from pyramid.interfaces import IRequestExtensions from pyramid.compat import text_, PY2 from pyramid.exceptions import ConfigurationError config = self._makeOne(autocommit=True) - def boomshaka(r): + def boomshaka(r): # pragma: no cover pass def get_bad_name(): @@ -185,7 +184,7 @@ class TestFactoriesMixin(unittest.TestCase): config = self._makeOne(autocommit=True) - def dummy_policy(environ, router): + def dummy_policy(environ, router): # pragma: no cover pass config.set_execution_policy(dummy_policy) diff --git a/tests/test_config/test_i18n.py b/tests/test_config/test_i18n.py index 5961e9ff2..b840c1976 100644 --- a/tests/test_config/test_i18n.py +++ b/tests/test_config/test_i18n.py @@ -27,7 +27,7 @@ class TestI18NConfiguratorMixin(unittest.TestCase): config = self._makeOne(autocommit=True) - def negotiator(request): + def negotiator(request): # pragma: no cover pass config.set_locale_negotiator(negotiator) @@ -120,8 +120,6 @@ class TestI18NConfiguratorMixin(unittest.TestCase): ) def test_add_translation_dirs_invalid_kwargs(self): - from pyramid.interfaces import ITranslationDirectories - config = self._makeOne(autocommit=True) with self.assertRaises(TypeError): config.add_translation_dirs('tests.pkgs.localeapp:locale', foo=1) diff --git a/tests/test_config/test_init.py b/tests/test_config/test_init.py index a7b19a1ac..2c92b60fb 100644 --- a/tests/test_config/test_init.py +++ b/tests/test_config/test_init.py @@ -1,6 +1,7 @@ -import unittest - import os +import unittest +from zope.interface import Interface +from zope.interface import implementer from pyramid.compat import im_func from pyramid.testing import skip_on @@ -320,7 +321,7 @@ class ConfiguratorTests(unittest.TestCase): from pyramid.interfaces import IExceptionResponse from pyramid.interfaces import IRequest - def exceptionresponse_view(context, request): + def exceptionresponse_view(context, request): # pragma: no cover pass config = self._makeOne(exceptionresponse_view=exceptionresponse_view) @@ -793,7 +794,8 @@ tests.test_config.dummy_include2""" reg = Registry() config = self._makeOne(reg) settings = { - 'pyramid.includes': """tests.test_config.dummy_include tests.test_config.dummy_include2""" + 'pyramid.includes': """tests.test_config.dummy_include tests.\ +test_config.dummy_include2""" } config.setup_registry(settings=settings) self.assertTrue(reg.included) @@ -963,7 +965,6 @@ tests.test_config.dummy_include2""" def test_include_threadlocals_active(self): from pyramid.threadlocal import get_current_registry - from tests import test_config stack = [] @@ -1308,10 +1309,10 @@ tests.test_config.dummy_include2""" def test_commit_conflict_simple(self): config = self._makeOne() - def view1(request): + def view1(request): # pragma: no cover pass - def view2(request): + def view2(request): # pragma: no cover pass config.add_view(view1) @@ -1321,10 +1322,10 @@ tests.test_config.dummy_include2""" def test_commit_conflict_resolved_with_include(self): config = self._makeOne() - def view1(request): + def view1(request): # pragma: no cover pass - def view2(request): + def view2(request): # pragma: no cover pass def includeme(config): @@ -1339,10 +1340,10 @@ tests.test_config.dummy_include2""" def test_commit_conflict_with_two_includes(self): config = self._makeOne() - def view1(request): + def view1(request): # pragma: no cover pass - def view2(request): + def view2(request): # pragma: no cover pass def includeme1(config): @@ -1365,13 +1366,13 @@ tests.test_config.dummy_include2""" def test_commit_conflict_resolved_with_two_includes_and_local(self): config = self._makeOne() - def view1(request): + def view1(request): # pragma: no cover pass - def view2(request): + def view2(request): # pragma: no cover pass - def view3(request): + def view3(request): # pragma: no cover pass def includeme1(config): @@ -1392,13 +1393,13 @@ tests.test_config.dummy_include2""" config = self._makeOne(autocommit=True) - def view1(request): + def view1(request): # pragma: no cover pass - def view2(request): + def view2(request): # pragma: no cover pass - def view3(request): + def view3(request): # pragma: no cover pass config.add_view(view1, renderer=null_renderer) @@ -1411,10 +1412,10 @@ tests.test_config.dummy_include2""" def test_conflict_set_notfound_view(self): config = self._makeOne() - def view1(request): + def view1(request): # pragma: no cover pass - def view2(request): + def view2(request): # pragma: no cover pass config.set_notfound_view(view1) @@ -1431,10 +1432,10 @@ tests.test_config.dummy_include2""" def test_conflict_set_forbidden_view(self): config = self._makeOne() - def view1(request): + def view1(request): # pragma: no cover pass - def view2(request): + def view2(request): # pragma: no cover pass config.set_forbidden_view(view1) @@ -1461,7 +1462,7 @@ tests.test_config.dummy_include2""" def test___getattr__matches(self): config = self._makeOne() - def foo(config): + def foo(config): # pragma: no cover pass directives = {'foo': (foo, True)} @@ -1472,7 +1473,7 @@ tests.test_config.dummy_include2""" def test___getattr__matches_no_action_wrap(self): config = self._makeOne() - def foo(config): + def foo(config): # pragma: no cover pass directives = {'foo': (foo, False)} @@ -1977,7 +1978,7 @@ class TestActionState(unittest.TestCase): def f(*a, **k): c.actions.append((3, g, (8,), {}, (), None, -1)) - def g(*a, **k): + def g(*a, **k): # pragma: no cover pass c.actions = [(1, f, (1,))] @@ -2004,7 +2005,7 @@ class TestActionState(unittest.TestCase): def f(*a, **k): pass - def g(*a, **k): + def g(*a, **k): # pragma: no cover pass c.actions = [(1, f, (1,), {}, (), None, -1), (1, g, (2,))] @@ -2018,7 +2019,7 @@ class TestActionState(unittest.TestCase): def f(*a, **k): c.actions.append((1, g, (8,))) - def g(*a, **k): + def g(*a, **k): # pragma: no cover pass c.actions = [(1, f, (1,), {}, (), None, -1)] @@ -2043,7 +2044,7 @@ class Test_reentrant_action_functional(unittest.TestCase): config = self._makeConfigurator() config.add_directive('add_auto_route', add_auto_route) - def my_view(request): + def my_view(request): # pragma: no cover return request.response config.add_auto_route('foo', my_view) @@ -2429,9 +2430,6 @@ class DummyThreadLocalManager(object): self.popped = True -from zope.interface import implementer - - @implementer(IDummy) class DummyEvent: pass @@ -2461,9 +2459,6 @@ class DummyRegistry(object): return self.util -from zope.interface import Interface - - class IOther(Interface): pass diff --git a/tests/test_config/test_routes.py b/tests/test_config/test_routes.py index 0999f8072..d6f45608d 100644 --- a/tests/test_config/test_routes.py +++ b/tests/test_config/test_routes.py @@ -164,10 +164,10 @@ class RoutesConfiguratorMixinTests(unittest.TestCase): config = self._makeOne(autocommit=True) - def pred1(context, request): + def pred1(context, request): # pragma: no cover pass - def pred2(context, request): + def pred2(context, request): # pragma: no cover pass with warnings.catch_warnings(record=True) as w: diff --git a/tests/test_config/test_security.py b/tests/test_config/test_security.py index 77f7f0440..5ebd78f8d 100644 --- a/tests/test_config/test_security.py +++ b/tests/test_config/test_security.py @@ -133,7 +133,7 @@ class ConfiguratorSecurityMethodsTests(unittest.TestCase): config = self._makeOne(autocommit=True) - def callback(request): + def callback(request): # pragma: no cover return True config.set_default_csrf_options( diff --git a/tests/test_config/test_testing.py b/tests/test_config/test_testing.py index c0a98f9ad..ce6659667 100644 --- a/tests/test_config/test_testing.py +++ b/tests/test_config/test_testing.py @@ -1,4 +1,5 @@ import unittest +from zope.interface import implementer from pyramid.compat import text_ from pyramid.security import AuthenticationAPIMixin, AuthorizationAPIMixin @@ -222,9 +223,6 @@ class TestingConfiguratorMixinTests(unittest.TestCase): renderer.assert_(request=request) -from zope.interface import implementer - - @implementer(IDummy) class DummyEvent: pass diff --git a/tests/test_config/test_tweens.py b/tests/test_config/test_tweens.py index ed41c9a43..805310c9a 100644 --- a/tests/test_config/test_tweens.py +++ b/tests/test_config/test_tweens.py @@ -17,10 +17,10 @@ class TestTweensConfiguratorMixin(unittest.TestCase): from pyramid.interfaces import ITweens from pyramid.tweens import excview_tween_factory - def factory1(handler, registry): + def factory1(handler, registry): # pragma: no cover return handler - def factory2(handler, registry): + def factory2(handler, registry): # pragma: no cover return handler config = self._makeOne() diff --git a/tests/test_config/test_util.py b/tests/test_config/test_util.py index a56c00082..50d143b2d 100644 --- a/tests/test_config/test_util.py +++ b/tests/test_config/test_util.py @@ -426,7 +426,7 @@ class TestDeprecatedPredicates(unittest.TestCase): with warnings.catch_warnings(record=True) as w: warnings.filterwarnings('always') - from pyramid.config.predicates import XHRPredicate + from pyramid.config.predicates import XHRPredicate # noqa: F401 self.assertEqual(len(w), 1) @@ -493,7 +493,7 @@ class DummyCustomPredicate(object): def __init__(self): self.__text__ = 'custom predicate' - def classmethod_predicate(*args): + def classmethod_predicate(*args): # pragma: no cover pass classmethod_predicate.__text__ = 'classmethod predicate' diff --git a/tests/test_config/test_views.py b/tests/test_config/test_views.py index 9b2a306f6..977944fdd 100644 --- a/tests/test_config/test_views.py +++ b/tests/test_config/test_views.py @@ -1,15 +1,16 @@ import os import unittest -from pyramid import testing - -from . import IDummy - -from . import dummy_view +from zope.interface import implementer +from pyramid import testing from pyramid.compat import im_func, text_ from pyramid.exceptions import ConfigurationError from pyramid.exceptions import ConfigurationExecutionError from pyramid.exceptions import ConfigurationConflictError +from pyramid.interfaces import IResponse, IRequest, IMultiView + +from . import IDummy +from . import dummy_view class TestViewsConfigurationMixin(unittest.TestCase): @@ -859,7 +860,7 @@ class TestViewsConfigurationMixin(unittest.TestCase): def view(context, request): return 'OK' - def view2(context, request): + def view2(context, request): # pragma: no cover return 'OK2' def view3(context, request): @@ -884,7 +885,7 @@ class TestViewsConfigurationMixin(unittest.TestCase): def view(context, request): return 'OK' - def view2(context, request): + def view2(context, request): # pragma: no cover return 'OK2' def view3(context, request): @@ -1332,7 +1333,7 @@ class TestViewsConfigurationMixin(unittest.TestCase): def __init__(self, request): pass - def unknown(context, request): + def unknown(context, request): # pragma: no cover return 'unknown' def view(context, request): @@ -1379,7 +1380,7 @@ class TestViewsConfigurationMixin(unittest.TestCase): def __init__(self, request): pass - def unknown(context, request): + def unknown(context, request): # pragma: no cover return 'unknown' def view(context, request): @@ -2048,7 +2049,7 @@ class TestViewsConfigurationMixin(unittest.TestCase): from pyramid.exceptions import BadCSRFToken from pyramid.renderers import null_renderer - def view(request): + def view(request): # pragma: no cover return 'OK' config = self._makeOne(autocommit=True) @@ -2251,13 +2252,12 @@ class TestViewsConfigurationMixin(unittest.TestCase): def test_add_view_class_method_no_attr(self): from pyramid.renderers import null_renderer - from zope.interface import directlyProvides from pyramid.exceptions import ConfigurationError config = self._makeOne(autocommit=True) class DummyViewClass(object): - def run(self): + def run(self): # pragma: no cover pass def configure_view(): @@ -2728,7 +2728,7 @@ class TestViewsConfigurationMixin(unittest.TestCase): config = self._makeOne(autocommit=True) config.add_route('foo', '/foo/') - def view(request): + def view(request): # pragma: no cover return Response('OK') config.add_notfound_view( @@ -2757,7 +2757,7 @@ class TestViewsConfigurationMixin(unittest.TestCase): config = self._makeOne(autocommit=True) config.add_route('foo', '/foo/') - def view(request): + def view(request): # pragma: no cover return Response('OK') config.add_notfound_view( @@ -2989,7 +2989,7 @@ class Test_runtime_exc_view(unittest.TestCase): def view1(context, request): return 'OK' - def view2(context, request): + def view2(context, request): # pragma: no cover raise AssertionError result_view = self._makeOne(view1, view2) @@ -2998,7 +2998,7 @@ class Test_runtime_exc_view(unittest.TestCase): self.assertEqual(result, 'OK') def test_call_dispatches_on_exception(self): - def view1(context, request): + def view1(context, request): # pragma: no cover raise AssertionError def view2(context, request): @@ -3011,15 +3011,15 @@ class Test_runtime_exc_view(unittest.TestCase): self.assertEqual(result, 'OK') def test_permitted(self): - def errfn(context, request): + def errfn(context, request): # pragma: no cover raise AssertionError - def view1(context, request): + def view1(context, request): # pragma: no cover raise AssertionError view1.__permitted__ = lambda c, r: 'OK' - def view2(context, request): + def view2(context, request): # pragma: no cover raise AssertionError view2.__permitted__ = errfn @@ -3029,15 +3029,15 @@ class Test_runtime_exc_view(unittest.TestCase): self.assertEqual(result, 'OK') def test_permitted_dispatches_on_exception(self): - def errfn(context, request): + def errfn(context, request): # pragma: no cover raise AssertionError - def view1(context, request): + def view1(context, request): # pragma: no cover raise AssertionError view1.__permitted__ = errfn - def view2(context, request): + def view2(context, request): # pragma: no cover raise AssertionError view2.__permitted__ = lambda c, r: 'OK' @@ -3055,17 +3055,17 @@ class Test_requestonly(unittest.TestCase): return requestonly(view, attr=attr) def test_defaults(self): - def aview(request, a=1, b=2): + def aview(request, a=1, b=2): # pragma: no cover pass self.assertTrue(self._callFUT(aview)) def test_otherattr(self): class AView(object): - def __init__(self, request, a=1, b=2): + def __init__(self, request, a=1, b=2): # pragma: no cover pass - def bleh(self): + def bleh(self): # pragma: no cover pass self.assertTrue(self._callFUT(AView, 'bleh')) @@ -3166,13 +3166,13 @@ class TestMultiView(unittest.TestCase): def test_add_with_phash_override_accept(self): mv = self._makeOne() - def view1(): + def view1(): # pragma: no cover pass - def view2(): + def view2(): # pragma: no cover pass - def view3(): + def view3(): # pragma: no cover pass mv.add(view1, 100, accept='text/html', phash='abc') @@ -3186,13 +3186,13 @@ class TestMultiView(unittest.TestCase): def test_add_with_phash_override_accept2(self): mv = self._makeOne() - def view1(): + def view1(): # pragma: no cover pass - def view2(): + def view2(): # pragma: no cover pass - def view3(): + def view3(): # pragma: no cover pass mv.add(view1, 100, accept='text/html', phash='abc') @@ -3207,10 +3207,10 @@ class TestMultiView(unittest.TestCase): # this failed on py3 at one point, because functions aren't orderable # and we were sorting the views via a plain sort() rather than # sort(key=itemgetter(0)). - def view1(request): + def view1(request): # pragma: no cover pass - def view2(request): + def view2(request): # pragma: no cover pass mv = self._makeOne() @@ -3692,12 +3692,12 @@ class Test_preserve_view_attrs(unittest.TestCase): self.assertTrue(result is view) def test_it_different_with_existing_original_view(self): - def view1(context, request): + def view1(context, request): # pragma: no cover pass view1.__original_view__ = 'abc' - def view2(context, request): + def view2(context, request): # pragma: no cover pass result = self._callFUT(view1, view2) @@ -3950,7 +3950,7 @@ class TestStaticURLInfo(unittest.TestCase): self.assertTrue(called[0]) def test_generate_url_cachebust_nomatch(self): - def fake_cb(*a, **kw): + def fake_cb(*a, **kw): # pragma: no cover raise AssertionError inst = self._makeOne() @@ -4188,7 +4188,7 @@ class Test_view_description(unittest.TestCase): return view_description(view) def test_with_text(self): - def view(): + def view(): # pragma: no cover pass view.__text__ = 'some text' @@ -4196,7 +4196,7 @@ class Test_view_description(unittest.TestCase): self.assertEqual(result, 'some text') def test_without_text(self): - def view(): + def view(): # pragma: no cover pass result = self._callFUT(view) @@ -4228,10 +4228,6 @@ class DummyRegistry: return self.utility or default -from zope.interface import implementer -from pyramid.interfaces import IResponse, IRequest - - @implementer(IResponse) class DummyResponse(object): content_type = None @@ -4295,10 +4291,6 @@ class DummyConfig: return {} -from zope.interface import implementer -from pyramid.interfaces import IMultiView - - @implementer(IMultiView) class DummyMultiView: def __init__(self): diff --git a/tests/test_events.py b/tests/test_events.py index a08cab637..25ed5fc0d 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -196,7 +196,7 @@ class TestSubscriber(unittest.TestCase): dec = self._makeOne(IFoo) - def foo(): + def foo(): # pragma: no cover pass config = DummyConfigurator() @@ -216,7 +216,7 @@ class TestSubscriber(unittest.TestCase): dec = self._makeOne(IFoo, IBar) - def foo(): + def foo(): # pragma: no cover pass config = DummyConfigurator() @@ -230,7 +230,7 @@ class TestSubscriber(unittest.TestCase): dec = self._makeOne() - def foo(): + def foo(): # pragma: no cover pass config = DummyConfigurator() @@ -250,7 +250,7 @@ class TestSubscriber(unittest.TestCase): dec = self._makeOne([IFoo, IBar]) - def foo(): + def foo(): # pragma: no cover pass config = DummyConfigurator() @@ -264,7 +264,7 @@ class TestSubscriber(unittest.TestCase): dummy_venusian = DummyVenusian() dec.venusian = dummy_venusian - def foo(): + def foo(): # pragma: no cover pass dec(foo) @@ -277,7 +277,7 @@ class TestSubscriber(unittest.TestCase): dummy_venusian = DummyVenusian() dec.venusian = dummy_venusian - def foo(): + def foo(): # pragma: no cover pass dec(foo) @@ -290,7 +290,7 @@ class TestSubscriber(unittest.TestCase): dec = self._makeOne(a=1) - def foo(): + def foo(): # pragma: no cover pass config = DummyConfigurator() diff --git a/tests/test_i18n.py b/tests/test_i18n.py index a830b8e0f..78891200d 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -1,13 +1,11 @@ # -*- coding: utf-8 -*- -# import os +import unittest +from pyramid import testing here = os.path.dirname(__file__) localedir = os.path.join(here, 'pkgs', 'localeapp', 'locale') -import unittest -from pyramid import testing - class TestTranslationString(unittest.TestCase): def _makeOne(self, *arg, **kw): diff --git a/tests/test_integration.py b/tests/test_integration.py index 250d6790d..28160eb7a 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- - import datetime import gc import locale import os import unittest +from webtest import TestApp +from zope.interface import Interface from pyramid.wsgi import wsgiapp from pyramid.view import view_config @@ -12,8 +13,7 @@ from pyramid.static import static_view from pyramid.testing import skip_on from pyramid.compat import text_, url_quote -from zope.interface import Interface -from webtest import TestApp +from .pkgs.exceptionviewapp.models import AnException, NotAnException # 5 years from now (more or less) fiveyrsfuture = datetime.datetime.utcnow() + datetime.timedelta(5 * 365) @@ -38,7 +38,7 @@ class WGSIAppPlusViewConfigTests(unittest.TestCase): import types self.assertTrue(getattr(wsgiapptest, ATTACH_ATTR)) - self.assertTrue(type(wsgiapptest) is types.FunctionType) + self.assertIsInstance(wsgiapptest, types.FunctionType) context = DummyContext() request = DummyRequest() result = wsgiapptest(context, request) @@ -450,7 +450,8 @@ class TestForbiddenView(IntegrationBase, unittest.TestCase): class TestViewPermissionBug(IntegrationBase, unittest.TestCase): - # view_execution_permitted bug as reported by Shane at http://lists.repoze.org/pipermail/repoze-dev/2010-October/003603.html + # view_execution_permitted bug as reported by Shane at + # http://lists.repoze.org/pipermail/repoze-dev/2010-October/003603.html package = 'tests.pkgs.permbugapp' def test_test(self): @@ -462,7 +463,8 @@ class TestViewPermissionBug(IntegrationBase, unittest.TestCase): class TestDefaultViewPermissionBug(IntegrationBase, unittest.TestCase): - # default_view_permission bug as reported by Wiggy at http://lists.repoze.org/pipermail/repoze-dev/2010-October/003602.html + # default_view_permission bug as reported by Wiggy at + # http://lists.repoze.org/pipermail/repoze-dev/2010-October/003602.html package = 'tests.pkgs.defpermbugapp' def test_x(self): @@ -478,8 +480,6 @@ class TestDefaultViewPermissionBug(IntegrationBase, unittest.TestCase): self.assertTrue(b'public' in res.body) -from .pkgs.exceptionviewapp.models import AnException, NotAnException - excroot = {'anexception': AnException(), 'notanexception': NotAnException()} diff --git a/tests/test_location.py b/tests/test_location.py index b48b7bdaa..163bb85aa 100644 --- a/tests/test_location.py +++ b/tests/test_location.py @@ -1,4 +1,6 @@ import unittest +from zope.interface import implementer +from pyramid.interfaces import ILocation class TestInside(unittest.TestCase): @@ -44,10 +46,6 @@ class TestLineage(unittest.TestCase): self.assertEqual(result, [o1]) -from pyramid.interfaces import ILocation -from zope.interface import implementer - - @implementer(ILocation) class Location(object): __name__ = __parent__ = None diff --git a/tests/test_registry.py b/tests/test_registry.py index f35a54dba..aee4f0e15 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -1,4 +1,6 @@ import unittest +from zope.interface import Interface +from zope.interface import implementer class TestRegistry(unittest.TestCase): @@ -441,10 +443,6 @@ class DummyIntrospectable(object): return hash((self.category_name,) + (self.discriminator,)) -from zope.interface import Interface -from zope.interface import implementer - - class IDummyEvent(Interface): pass diff --git a/tests/test_request.py b/tests/test_request.py index 13e424f79..dcac501aa 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -1,4 +1,3 @@ -from collections import deque import unittest from pyramid import testing @@ -153,7 +152,8 @@ class TestRequest(unittest.TestCase): def test__process_response_callback_adding_response_callback(self): """ - When a response callback adds another callback, that new callback should still be called. + When a response callback adds another callback, that new callback + should still be called. See https://github.com/Pylons/pyramid/pull/1373 """ diff --git a/tests/test_response.py b/tests/test_response.py index 6ea7125b5..5231e47f0 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -166,7 +166,7 @@ class TestResponseAdapter(unittest.TestCase): dec = self._makeOne(IFoo) - def foo(): + def foo(): # pragma: no cover pass config = DummyConfigurator() @@ -186,7 +186,7 @@ class TestResponseAdapter(unittest.TestCase): dec = self._makeOne(IFoo, IBar) - def foo(): + def foo(): # pragma: no cover pass config = DummyConfigurator() @@ -205,7 +205,7 @@ class TestResponseAdapter(unittest.TestCase): dummy_venusian = DummyVenusian() dec.venusian = dummy_venusian - def foo(): + def foo(): # pragma: no cover pass dec(foo) @@ -223,7 +223,7 @@ class TestResponseAdapter(unittest.TestCase): dummy_venusian = DummyVenusian() dec.venusian = dummy_venusian - def foo(): + def foo(): # pragma: no cover pass dec(foo) diff --git a/tests/test_router.py b/tests/test_router.py index f06cfe5bc..3e66757f6 100644 --- a/tests/test_router.py +++ b/tests/test_router.py @@ -1,6 +1,8 @@ import unittest +from zope.interface import implementer from pyramid import testing +from pyramid.interfaces import IResponse class TestRouter(unittest.TestCase): @@ -1683,10 +1685,6 @@ class DummyStartResponse: self.headers = headers -from pyramid.interfaces import IResponse -from zope.interface import implementer - - @implementer(IResponse) class DummyResponse(object): headerlist = () diff --git a/tests/test_scripting.py b/tests/test_scripting.py index 6bb293a0d..8f74f35f8 100644 --- a/tests/test_scripting.py +++ b/tests/test_scripting.py @@ -121,7 +121,7 @@ class Test_prepare(unittest.TestCase): request.context = context registry = request.registry = self._makeRegistry() info = self._callFUT(request=request, registry=registry) - root, closer, root = info['root'], info['closer'], info['root'] + closer = info['closer'] closer() self.assertEqual(request.context, context) @@ -136,7 +136,7 @@ class Test_prepare(unittest.TestCase): registry = request.registry = self._makeRegistry([exts, DummyFactory]) info = self._callFUT(request=request, registry=registry) self.assertEqual(request.foo, 'bar') - root, closer = info['root'], info['closer'] + closer = info['closer'] closer() def test_it_is_a_context_manager(self): diff --git a/tests/test_scripts/dummy.py b/tests/test_scripts/dummy.py index 69e69a280..8e340f645 100644 --- a/tests/test_scripts/dummy.py +++ b/tests/test_scripts/dummy.py @@ -1,3 +1,7 @@ +from zope.interface import implementer +from pyramid.interfaces import IMultiView + + class DummyTweens(object): def __init__(self, implicit, explicit): self._implicit = implicit @@ -87,14 +91,10 @@ class DummyView(object): def __init__(self, **attrs): self.__request_attrs__ = attrs - def view(context, request): + def view(context, request): # pragma: no cover pass -from zope.interface import implementer -from pyramid.interfaces import IMultiView - - @implementer(IMultiView) class DummyMultiView(object): def __init__(self, *views, **attrs): diff --git a/tests/test_scripts/test_proutes.py b/tests/test_scripts/test_proutes.py index 5bbfa9f25..5e3f359f6 100644 --- a/tests/test_scripts/test_proutes.py +++ b/tests/test_scripts/test_proutes.py @@ -121,7 +121,7 @@ class TestPRoutesCommand(unittest.TestCase): registry = self._makeRegistry() - def view(): + def view(): # pragma: no cover pass class IMyRoute(Interface): @@ -148,7 +148,7 @@ class TestPRoutesCommand(unittest.TestCase): registry = self._makeRegistry() - def view(): + def view(): # pragma: no cover pass class IMyRoute(Interface): @@ -181,7 +181,7 @@ class TestPRoutesCommand(unittest.TestCase): registry = self._makeRegistry() - def view(): + def view(): # pragma: no cover pass class IMyRoute(Interface): @@ -254,7 +254,7 @@ class TestPRoutesCommand(unittest.TestCase): registry = self._makeRegistry() - def view(): + def view(): # pragma: no cover pass class IMyRoot(Interface): @@ -269,7 +269,7 @@ class TestPRoutesCommand(unittest.TestCase): registry.registerUtility(IMyRoute, IRouteRequest, name='a') command = self._makeOne() - def factory(request): + def factory(request): # pragma: no cover pass route = dummy.DummyRoute('a', '/a', factory=factory) @@ -291,7 +291,7 @@ class TestPRoutesCommand(unittest.TestCase): registry = self._makeRegistry() - def view(): + def view(): # pragma: no cover pass class IMyRoute(Interface): @@ -334,7 +334,7 @@ class TestPRoutesCommand(unittest.TestCase): def test_one_route_all_methods_view_only_post(self): from pyramid.renderers import null_renderer as nr - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -362,7 +362,7 @@ class TestPRoutesCommand(unittest.TestCase): def test_one_route_only_post_view_all_methods(self): from pyramid.renderers import null_renderer as nr - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -388,7 +388,7 @@ class TestPRoutesCommand(unittest.TestCase): def test_one_route_only_post_view_post_and_get(self): from pyramid.renderers import null_renderer as nr - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -419,7 +419,7 @@ class TestPRoutesCommand(unittest.TestCase): def test_route_request_method_mismatch(self): from pyramid.renderers import null_renderer as nr - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -446,8 +446,6 @@ class TestPRoutesCommand(unittest.TestCase): self.assertEqual(compare_to, expected) def test_route_static_views(self): - from pyramid.renderers import null_renderer as nr - config = self._makeConfig(autocommit=True) config.add_static_view('static', 'static', cache_max_age=3600) path2 = os.path.normpath('/var/www/static') @@ -486,8 +484,6 @@ class TestPRoutesCommand(unittest.TestCase): self.assertEqual(data, expected[index]) def test_route_no_view(self): - from pyramid.renderers import null_renderer as nr - config = self._makeConfig(autocommit=True) config.add_route('foo', '/a/b', request_method='POST') @@ -507,7 +503,7 @@ class TestPRoutesCommand(unittest.TestCase): config1 = self._makeConfig(autocommit=True) - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config1.add_route('foo', '/a/b', request_method='POST') @@ -532,7 +528,7 @@ class TestPRoutesCommand(unittest.TestCase): from pyramid.renderers import null_renderer as nr from pyramid.config import not_ - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -564,7 +560,7 @@ class TestPRoutesCommand(unittest.TestCase): from pyramid.renderers import null_renderer as nr from pyramid.config import not_ - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -596,10 +592,10 @@ class TestPRoutesCommand(unittest.TestCase): from pyramid.renderers import null_renderer as nr from pyramid.config import not_ - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' - def view2(context, request): + def view2(context, request): # pragma: no cover return 'view2' config = self._makeConfig(autocommit=True) @@ -641,7 +637,7 @@ class TestPRoutesCommand(unittest.TestCase): from pyramid.renderers import null_renderer as nr from pyramid.config import not_ - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -672,7 +668,7 @@ class TestPRoutesCommand(unittest.TestCase): from pyramid.renderers import null_renderer as nr from pyramid.config import not_ - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -702,7 +698,7 @@ class TestPRoutesCommand(unittest.TestCase): from pyramid.renderers import null_renderer as nr from pyramid.config import not_ - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -736,7 +732,7 @@ class TestPRoutesCommand(unittest.TestCase): from pyramid.renderers import null_renderer as nr from pyramid.config import not_ - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -770,7 +766,7 @@ class TestPRoutesCommand(unittest.TestCase): from pyramid.renderers import null_renderer as nr from pyramid.config import not_ - def view1(context, request): + def view1(context, request): # pragma: no cover return 'view1' config = self._makeConfig(autocommit=True) @@ -801,8 +797,6 @@ class TestPRoutesCommand(unittest.TestCase): self.assertEqual(L[0].split(), ['Method', 'Name']) def test_static_routes_included_in_list(self): - from pyramid.renderers import null_renderer as nr - config = self._makeConfig(autocommit=True) config.add_route('foo', 'http://example.com/bar.aspx', static=True) diff --git a/tests/test_scripts/test_ptweens.py b/tests/test_scripts/test_ptweens.py index a7fe6f651..ee50887f6 100644 --- a/tests/test_scripts/test_ptweens.py +++ b/tests/test_scripts/test_ptweens.py @@ -48,7 +48,8 @@ class TestPTweensCommand(unittest.TestCase): self.assertEqual(result, 0) self.assertEqual( L[0], - '"pyramid.tweens" config value set (explicitly ordered tweens used)', + '"pyramid.tweens" config value set (explicitly ordered tweens ' + 'used)', ) def test__get_tweens(self): diff --git a/tests/test_scripts/test_pviews.py b/tests/test_scripts/test_pviews.py index cdb3c1c33..0b26a9cf3 100644 --- a/tests/test_scripts/test_pviews.py +++ b/tests/test_scripts/test_pviews.py @@ -75,7 +75,7 @@ class TestPViewsCommand(unittest.TestCase): registry = Registry() - def view1(): + def view1(): # pragma: no cover pass request = dummy.DummyRequest({'PATH_INFO': '/a'}) @@ -128,7 +128,7 @@ class TestPViewsCommand(unittest.TestCase): registry = Registry() - def view(): + def view(): # pragma: no cover pass class IMyRoot(Interface): @@ -167,10 +167,10 @@ class TestPViewsCommand(unittest.TestCase): registry = Registry() - def view1(): + def view1(): # pragma: no cover pass - def view2(): + def view2(): # pragma: no cover pass class IMyRoot(Interface): @@ -213,10 +213,10 @@ class TestPViewsCommand(unittest.TestCase): registry = Registry() - def view1(): + def view1(): # pragma: no cover pass - def view2(): + def view2(): # pragma: no cover pass class IMyRoot(Interface): @@ -259,7 +259,7 @@ class TestPViewsCommand(unittest.TestCase): def test__find_multi_routes_all_match(self): command = self._makeOne() - def factory(request): + def factory(request): # pragma: no cover pass routes = [ @@ -280,7 +280,7 @@ class TestPViewsCommand(unittest.TestCase): def test__find_multi_routes_some_match(self): command = self._makeOne() - def factory(request): + def factory(request): # pragma: no cover pass routes = [ @@ -295,7 +295,7 @@ class TestPViewsCommand(unittest.TestCase): def test__find_multi_routes_none_match(self): command = self._makeOne() - def factory(request): + def factory(request): # pragma: no cover pass routes = [ @@ -363,7 +363,7 @@ class TestPViewsCommand(unittest.TestCase): L = [] command.out = L.append - def view(): + def view(): # pragma: no cover pass view.__request_attrs__ = {'context': 'context', 'view_name': 'a'} @@ -405,7 +405,7 @@ class TestPViewsCommand(unittest.TestCase): L = [] command.out = L.append - def predicate(): + def predicate(): # pragma: no cover pass predicate.text = lambda *arg: "predicate = x" @@ -483,7 +483,7 @@ class TestPViewsCommand(unittest.TestCase): L = [] command.out = L.append - def predicate(): + def predicate(): # pragma: no cover pass predicate.text = lambda *arg: "predicate = x" @@ -563,7 +563,7 @@ class TestPViewsCommand(unittest.TestCase): L = [] command.out = L.append - def predicate(): + def predicate(): # pragma: no cover pass predicate.text = lambda *arg: "predicate = x" diff --git a/tests/test_testing.py b/tests/test_testing.py index b5c689794..90e30c94f 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -1,5 +1,7 @@ import unittest from zope.component import getSiteManager +from zope.interface import Interface +from zope.interface import implementer from pyramid import testing @@ -561,7 +563,7 @@ class Test_skip_on(unittest.TestCase): return skip_on(*platforms) def test_wrong_platform(self): - def foo(): + def foo(): # pragma: no cover return True decorated = self._callFUT('wrong')(foo) @@ -666,10 +668,6 @@ class TestDummySession(unittest.TestCase): self.assertTrue(len(token) >= 1) -from zope.interface import Interface -from zope.interface import implementer - - class IDummy(Interface): pass diff --git a/tests/test_traversal.py b/tests/test_traversal.py index 8521844b0..61e480cbc 100644 --- a/tests/test_traversal.py +++ b/tests/test_traversal.py @@ -1226,7 +1226,8 @@ class Test__join_path_tuple(unittest.TestCase): def test_segments_with_unsafes(self): safe_segments = tuple( - u"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._~!$&'()*+,;=:@" + u"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + u"-._~!$&'()*+,;=:@" ) result = self._callFUT(safe_segments) self.assertEqual(result, u'/'.join(safe_segments)) diff --git a/tests/test_tweens.py b/tests/test_tweens.py index ab9b8b0cd..054f4360d 100644 --- a/tests/test_tweens.py +++ b/tests/test_tweens.py @@ -69,7 +69,7 @@ class Test_excview_tween_factory(unittest.TestCase): def test_it_reraises_on_mismatch(self): from pyramid.request import Request - def excview(request): + def excview(request): # pragma: no cover pass self.config.add_view(excview, context=ValueError, request_method='GET') diff --git a/tests/test_url.py b/tests/test_url.py index 3acfbc876..94a0a61c9 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -1,6 +1,5 @@ import os import unittest -import warnings from pyramid import testing diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py index e90fbfa0b..57f81b527 100644 --- a/tests/test_urldispatch.py +++ b/tests/test_urldispatch.py @@ -26,8 +26,8 @@ class TestRoute(unittest.TestCase): self.assertEqual(route.path, ':path') self.assertEqual(route.name, 'name') self.assertEqual(route.factory, 'factory') - self.assertTrue(route.generate.__class__ is types.FunctionType) - self.assertTrue(route.match.__class__ is types.FunctionType) + self.assertIsInstance(route.generate, types.FunctionType) + self.assertIsInstance(route.match, types.FunctionType) def test_ctor_defaults(self): import types @@ -37,8 +37,8 @@ class TestRoute(unittest.TestCase): self.assertEqual(route.path, ':path') self.assertEqual(route.name, 'name') self.assertEqual(route.factory, None) - self.assertTrue(route.generate.__class__ is types.FunctionType) - self.assertTrue(route.match.__class__ is types.FunctionType) + self.assertIsInstance(route.generate, types.FunctionType) + self.assertIsInstance(route.match, types.FunctionType) def test_match(self): route = self._makeOne('name', ':path') @@ -501,7 +501,7 @@ class TestCompileRouteFunctional(unittest.TestCase): ) self.matches('*traverse', '/zzz/abc', {'traverse': ('zzz', 'abc')}) self.matches('*traverse', '/zzz/ abc', {'traverse': ('zzz', ' abc')}) - #'/La%20Pe%C3%B1a' + # '/La%20Pe%C3%B1a' self.matches( '{x}', text_(b'/La Pe\xc3\xb1a', 'utf-8'), @@ -544,7 +544,7 @@ class TestCompileRouteFunctional(unittest.TestCase): ) self.matches('*traverse', '/zzz/abc', {'traverse': ('zzz', 'abc')}) self.matches('*traverse', '/zzz/ abc', {'traverse': ('zzz', ' abc')}) - #'/La%20Pe%C3%B1a' + # '/La%20Pe%C3%B1a' # pattern, path, expected self.matches( ':x', diff --git a/tests/test_util.py b/tests/test_util.py index 307c1a5f8..a36655f6f 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -64,7 +64,7 @@ class Test_InstancePropertyHelper(unittest.TestCase): self.assertEqual(1, foo.y) def test_property_without_name(self): - def worker(obj): + def worker(obj): # pragma: no cover pass foo = Dummy() @@ -86,7 +86,7 @@ class Test_InstancePropertyHelper(unittest.TestCase): self.assertEqual(2, foo.x) def test_property_with_reify(self): - def worker(obj): + def worker(obj): # pragma: no cover pass foo = Dummy() @@ -101,7 +101,7 @@ class Test_InstancePropertyHelper(unittest.TestCase): ) def test_override_property(self): - def worker(obj): + def worker(obj): # pragma: no cover pass foo = Dummy() @@ -114,7 +114,7 @@ class Test_InstancePropertyHelper(unittest.TestCase): self.assertRaises(AttributeError, doit) def test_override_reify(self): - def worker(obj): + def worker(obj): # pragma: no cover pass foo = Dummy() @@ -272,7 +272,7 @@ class Test_InstancePropertyMixin(unittest.TestCase): self.assertEqual(1, foo.y) def test_property_without_name(self): - def worker(obj): + def worker(obj): # pragma: no cover pass foo = self._makeOne() @@ -290,7 +290,7 @@ class Test_InstancePropertyMixin(unittest.TestCase): self.assertEqual(2, foo.x) def test_property_with_reify(self): - def worker(obj): + def worker(obj): # pragma: no cover pass foo = self._makeOne() @@ -303,7 +303,7 @@ class Test_InstancePropertyMixin(unittest.TestCase): ) def test_override_property(self): - def worker(obj): + def worker(obj): # pragma: no cover pass foo = self._makeOne() @@ -315,7 +315,7 @@ class Test_InstancePropertyMixin(unittest.TestCase): self.assertRaises(AttributeError, doit) def test_override_reify(self): - def worker(obj): + def worker(obj): # pragma: no cover pass foo = self._makeOne() @@ -926,7 +926,7 @@ class Test_hide_attrs(unittest.TestCase): self.assertTrue('foo' not in obj.__dict__) -def dummyfunc(): +def dummyfunc(): # pragma: no cover pass diff --git a/tests/test_view.py b/tests/test_view.py index 039605408..f82480169 100644 --- a/tests/test_view.py +++ b/tests/test_view.py @@ -1,11 +1,11 @@ import unittest -import sys - +from zope.interface import Interface from zope.interface import implementer +import sys from pyramid import testing - from pyramid.interfaces import IRequest +from pyramid.interfaces import IResponse class BaseTest(object): @@ -68,7 +68,7 @@ class Test_notfound_view_config(BaseTest, unittest.TestCase): ) def test_it_function(self): - def view(request): + def view(request): # pragma: no cover pass decorator = self._makeOne( @@ -119,7 +119,7 @@ class Test_notfound_view_config(BaseTest, unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass decorator(foo) @@ -143,7 +143,7 @@ class Test_forbidden_view_config(BaseTest, unittest.TestCase): ) def test_it_function(self): - def view(request): + def view(request): # pragma: no cover pass decorator = self._makeOne(attr='attr', renderer='renderer') @@ -191,7 +191,7 @@ class Test_forbidden_view_config(BaseTest, unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass decorator(foo) @@ -228,7 +228,7 @@ class Test_exception_view_config(BaseTest, unittest.TestCase): ) def test_it_function(self): - def view(request): + def view(request): # pragma: no cover pass decorator = self._makeOne(context=Exception, renderer='renderer') @@ -276,7 +276,7 @@ class Test_exception_view_config(BaseTest, unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass decorator(foo) @@ -549,7 +549,7 @@ class TestViewConfigDecorator(unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass wrapped = decorator(foo) @@ -611,7 +611,7 @@ class TestViewConfigDecorator(unittest.TestCase): decorator2 = self._makeOne(name='2') decorator2.venusian = venusian2 - def foo(): + def foo(): # pragma: no cover pass wrapped1 = decorator1(foo) @@ -631,10 +631,10 @@ class TestViewConfigDecorator(unittest.TestCase): decorator.venusian = venusian decorator.venusian.info.scope = 'class' - def foo(self): + def foo(self): # pragma: no cover pass - def bar(self): + def bar(self): # pragma: no cover pass class foo(object): @@ -652,7 +652,7 @@ class TestViewConfigDecorator(unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(context, request): + def foo(context, request): # pragma: no cover pass decorated = decorator(foo) @@ -668,7 +668,7 @@ class TestViewConfigDecorator(unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass wrapped = decorator(foo) @@ -687,7 +687,7 @@ class TestViewConfigDecorator(unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass wrapped = decorator(foo) @@ -711,7 +711,7 @@ class TestViewConfigDecorator(unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass wrapped = decorator(foo) @@ -729,7 +729,7 @@ class TestViewConfigDecorator(unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass decorator(foo) @@ -742,7 +742,7 @@ class TestViewConfigDecorator(unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass decorator(foo) @@ -755,7 +755,7 @@ class TestViewConfigDecorator(unittest.TestCase): venusian = DummyVenusian() decorator.venusian = venusian - def foo(): + def foo(): # pragma: no cover pass decorator(foo) @@ -1091,7 +1091,7 @@ class TestViewMethodsMixin(unittest.TestCase): def test_it_rejects_secured_view(self): from pyramid.exceptions import Forbidden - def exc_view(exc, request): + def exc_view(exc, request): # pragma: no cover pass self.config.testing_securitypolicy(permissive=False) @@ -1147,7 +1147,7 @@ class TestViewMethodsMixin(unittest.TestCase): def test_it_raises_predicate_mismatch(self): from pyramid.exceptions import PredicateMismatch - def exc_view(exc, request): + def exc_view(exc, request): # pragma: no cover pass self.config.add_view( @@ -1164,7 +1164,7 @@ class TestViewMethodsMixin(unittest.TestCase): self.fail() def test_it_reraises_after_predicate_mismatch(self): - def exc_view(exc, request): + def exc_view(exc, request): # pragma: no cover pass self.config.add_view( @@ -1211,9 +1211,6 @@ class DummyRequest: self.environ = environ -from pyramid.interfaces import IResponse - - @implementer(IResponse) class DummyResponse(object): headerlist = () @@ -1228,9 +1225,6 @@ class DummyResponse(object): self.app_iter = [body] -from zope.interface import Interface - - class IContext(Interface): pass diff --git a/tests/test_viewderivers.py b/tests/test_viewderivers.py index 4ce0b8a9e..a1455ed92 100644 --- a/tests/test_viewderivers.py +++ b/tests/test_viewderivers.py @@ -87,14 +87,15 @@ class TestDeriveView(unittest.TestCase): msg = e.args[0] self.assertTrue( msg.startswith( - 'Could not convert return value of the view callable object ' - '<tests.test_viewderivers.' + 'Could not convert return value of the view callable ' + 'object <tests.test_viewderivers.' ) ) self.assertTrue( msg.endswith( - '> into a response object. The value returned was None. You ' - 'may have forgotten to return a value from the view callable.' + '> into a response object. The value returned was None. ' + 'You may have forgotten to return a value from the view ' + 'callable.' ) ) else: # pragma: no cover @@ -121,7 +122,6 @@ class TestDeriveView(unittest.TestCase): def view(request): return r - renderer = object() result = self.config.derive_view(view) self.assertFalse(result is view) response = result(None, None) @@ -730,7 +730,7 @@ class TestDeriveView(unittest.TestCase): from pyramid.interfaces import IAuthorizationPolicy from pyramid.httpexceptions import HTTPForbidden - def myview(request): + def myview(request): # pragma: no cover pass self.config.registry.settings = {} @@ -781,7 +781,7 @@ class TestDeriveView(unittest.TestCase): def view(request): raise ValueError - def excview(request): + def excview(request): # pragma: no cover pass self._registerSecurityPolicy(False) @@ -850,7 +850,7 @@ class TestDeriveView(unittest.TestCase): def test_predicate_mismatch_view_has_name(self): from pyramid.exceptions import PredicateMismatch - def myview(request): + def myview(request): # pragma: no cover pass def predicate1(context, request): @@ -872,7 +872,7 @@ class TestDeriveView(unittest.TestCase): def test_predicate_mismatch_exception_has_text_in_detail(self): from pyramid.exceptions import PredicateMismatch - def myview(request): + def myview(request): # pragma: no cover pass def predicate1(context, request): @@ -1210,7 +1210,7 @@ class TestDeriveView(unittest.TestCase): return wrapped - def view(context, request): + def view(context, request): # pragma: no cover return 'NOTOK' result = self.config._derive_view(view, mapper=mapper) @@ -1232,7 +1232,7 @@ class TestDeriveView(unittest.TestCase): return inner - def view(context, request): + def view(context, request): # pragma: no cover return 'NOTOK' view.__view_mapper__ = mapper @@ -1257,7 +1257,7 @@ class TestDeriveView(unittest.TestCase): self.config.set_view_mapper(mapper) - def view(context, request): + def view(context, request): # pragma: no cover return 'NOTOK' result = self.config.derive_view(view) @@ -1267,14 +1267,14 @@ class TestDeriveView(unittest.TestCase): def test_attr_wrapped_view_branching_default_phash(self): from pyramid.config.util import DEFAULT_PHASH - def view(context, request): + def view(context, request): # pragma: no cover pass result = self.config._derive_view(view, phash=DEFAULT_PHASH) self.assertEqual(result.__wraps__, view) def test_attr_wrapped_view_branching_nondefault_phash(self): - def view(context, request): + def view(context, request): # pragma: no cover pass result = self.config._derive_view(view, phash='nondefault') @@ -1406,7 +1406,7 @@ class TestDeriveView(unittest.TestCase): self.assertFalse('Cache-Control' in headers) def test_http_cached_view_bad_tuple(self): - def view(request): + def view(request): # pragma: no cover pass self.assertRaises( @@ -1431,7 +1431,7 @@ class TestDeriveView(unittest.TestCase): def test_csrf_view_fails_with_bad_POST_header(self): from pyramid.exceptions import BadCSRFToken - def inner_view(request): + def inner_view(request): # pragma: no cover pass request = self._makeRequest() @@ -1460,7 +1460,7 @@ class TestDeriveView(unittest.TestCase): def test_csrf_view_fails_with_bad_POST_token(self): from pyramid.exceptions import BadCSRFToken - def inner_view(request): + def inner_view(request): # pragma: no cover pass request = self._makeRequest() @@ -1507,7 +1507,7 @@ class TestDeriveView(unittest.TestCase): def test_csrf_view_fails_on_bad_PUT_header(self): from pyramid.exceptions import BadCSRFToken - def inner_view(request): + def inner_view(request): # pragma: no cover pass request = self._makeRequest() @@ -1521,7 +1521,7 @@ class TestDeriveView(unittest.TestCase): def test_csrf_view_fails_on_bad_referrer(self): from pyramid.exceptions import BadCSRFOrigin - def inner_view(request): + def inner_view(request): # pragma: no cover pass request = self._makeRequest() @@ -1537,7 +1537,7 @@ class TestDeriveView(unittest.TestCase): def test_csrf_view_fails_on_bad_origin(self): from pyramid.exceptions import BadCSRFOrigin - def inner_view(request): + def inner_view(request): # pragma: no cover pass request = self._makeRequest() @@ -1553,7 +1553,7 @@ class TestDeriveView(unittest.TestCase): def test_csrf_view_enabled_by_default(self): from pyramid.exceptions import BadCSRFToken - def inner_view(request): + def inner_view(request): # pragma: no cover pass request = self._makeRequest() @@ -1570,7 +1570,7 @@ class TestDeriveView(unittest.TestCase): from pyramid.exceptions import BadCSRFToken - def inner_view(request): + def inner_view(request): # pragma: no cover pass request = self._makeRequest() @@ -1696,7 +1696,7 @@ class TestDeriveView(unittest.TestCase): def view(request): raise ValueError - def excview(request): + def excview(request): # pragma: no cover pass self.config.set_default_csrf_options(require_csrf=True) @@ -1879,7 +1879,7 @@ class TestAddDeriver(unittest.TestCase): self.assertFalse(response.deriv) self.config.add_view_deriver(deriv, 'test_deriv') - result = self.config._derive_view(view) + result = self.config._derive_view(view) # noqa: F841 self.assertTrue(response.deriv) def test_override_deriver(self): @@ -1906,7 +1906,7 @@ class TestAddDeriver(unittest.TestCase): flags.clear() view2 = AView() self.config.add_view_deriver(deriv2, 'test_deriv') - result = self.config._derive_view(view2) + result = self.config._derive_view(view2) # noqa: F841 self.assertFalse(flags.get('deriv1')) self.assertTrue(flags.get('deriv2')) @@ -1928,7 +1928,7 @@ class TestAddDeriver(unittest.TestCase): self.config.add_view_deriver( deriv1, name='mapped_view', under='rendered_view', over=VIEW ) - result = self.config._derive_view(view) + result = self.config._derive_view(view) # noqa: F841 self.assertTrue(flags.get('deriv1')) def test_add_multi_derivers_ordered(self): @@ -1953,13 +1953,13 @@ class TestAddDeriver(unittest.TestCase): self.config.add_view_deriver(deriv1, 'deriv1') self.config.add_view_deriver(deriv2, 'deriv2', INGRESS, 'deriv1') self.config.add_view_deriver(deriv3, 'deriv3', 'deriv2', 'deriv1') - result = self.config._derive_view(view) + result = self.config._derive_view(view) # noqa: F841 self.assertEqual(response.deriv, ['deriv1', 'deriv3', 'deriv2']) def test_add_deriver_without_name(self): from pyramid.interfaces import IViewDerivers - def deriv1(view, info): + def deriv1(view, info): # pragma: no cover pass self.config.add_view_deriver(deriv1) @@ -1970,7 +1970,7 @@ class TestAddDeriver(unittest.TestCase): from pyramid.exceptions import ConfigurationError from pyramid.viewderivers import INGRESS - def deriv1(view, info): + def deriv1(view, info): # pragma: no cover pass self.assertRaises( @@ -1981,7 +1981,7 @@ class TestAddDeriver(unittest.TestCase): from pyramid.exceptions import ConfigurationError from pyramid.viewderivers import INGRESS - def deriv1(view, info): + def deriv1(view, info): # pragma: no cover pass try: @@ -1995,7 +1995,7 @@ class TestAddDeriver(unittest.TestCase): from pyramid.exceptions import ConfigurationError from pyramid.viewderivers import VIEW - def deriv1(view, info): + def deriv1(view, info): # pragma: no cover pass try: @@ -2008,7 +2008,7 @@ class TestAddDeriver(unittest.TestCase): def test_add_deriver_enforces_mapped_view_is_last(self): from pyramid.exceptions import ConfigurationError - def deriv1(view, info): + def deriv1(view, info): # pragma: no cover pass try: @@ -2082,7 +2082,7 @@ class TestDeriverIntegration(unittest.TestCase): def test_unexpected_view_options(self): from pyramid.exceptions import ConfigurationError - def deriv1(view, info): + def deriv1(view, info): # pragma: no cover pass self.config.add_view_deriver(deriv1, 'deriv1') |
