From b0ebdf0bf54b1eb40d714710e1fcaf24a055003e Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 22 Feb 2012 22:09:30 -0500 Subject: - ``pyramid.config.Configurator.with_package`` didn't work if the Configurator was an old-style ``pyramid.configuration.Configurator`` instance. --- CHANGES.txt | 10 ++++++++++ pyramid/configuration.py | 2 ++ pyramid/tests/test_configuration.py | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index bcedb19a1..d07d49f8b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,13 @@ +Next release +============ + +Bug Fixes +--------- + +- ``pyramid.config.Configurator.with_package`` didn't work if the + Configurator was an old-style ``pyramid.configuration.Configurator`` + instance. + 1.3a9 (2012-02-22) ================== diff --git a/pyramid/configuration.py b/pyramid/configuration.py index f6543906e..802c10d1f 100644 --- a/pyramid/configuration.py +++ b/pyramid/configuration.py @@ -29,6 +29,7 @@ class Configurator(BaseConfigurator): session_factory=None, autocommit=True, route_prefix=None, + introspection=True, ): if package is None: package = caller_package() @@ -49,6 +50,7 @@ class Configurator(BaseConfigurator): session_factory=session_factory, autocommit=autocommit, route_prefix=route_prefix, + introspection=introspection, ) deprecated( diff --git a/pyramid/tests/test_configuration.py b/pyramid/tests/test_configuration.py index 688a597f6..0a98bcb5c 100644 --- a/pyramid/tests/test_configuration.py +++ b/pyramid/tests/test_configuration.py @@ -22,4 +22,10 @@ class ConfiguratorTests(unittest.TestCase): config = self._makeOne(package='pyramid') self.assertEqual(config.package, pyramid) + def test_with_package(self): + import pyramid + config = self._makeOne() + newconfig = config.with_package('pyramid') + self.assertEqual(newconfig.package, pyramid) + -- cgit v1.2.3 From 3b9e5f1df23e42eabfc41e8726c27a7227230b61 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 23 Feb 2012 20:42:57 -0500 Subject: fix --- docs/narr/assets.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/narr/assets.rst b/docs/narr/assets.rst index 22b38c929..e8e915297 100644 --- a/docs/narr/assets.rst +++ b/docs/narr/assets.rst @@ -379,13 +379,12 @@ do so, do things "by hand". First define the view callable. The above bit of code within ``favicon_view`` computes "here", which is a path relative to the Python file in which the function is defined. It then -uses the Python ``open`` function to obtain a file handle to a file within -"here" named ``static``, and returns a :class:`pyramid.response.FileResponse` -using the file path as the response's ``path`` argument and the request as -the response's ``request`` argument. :class:`pyramid.response.FileResponse` -will serve the file as quickly as possible when it's used this way. It makes -sure to set the right content length and content_type too based on the file -extension of the file you pass. +creates a :class:`pyramid.response.FileResponse` using the file path as the +response's ``path`` argument and the request as the response's ``request`` +argument. :class:`pyramid.response.FileResponse` will serve the file as +quickly as possible when it's used this way. It makes sure to set the right +content length and content_type too based on the file extension of the file +you pass. You might register such a view via configuration as a view callable that should be called as the result of a traversal: -- cgit v1.2.3 From 64c913abc0a23c4dcdbbce95be4459d664b78cbd Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 23 Feb 2012 21:40:31 -0500 Subject: fixes #307 --- pyramid/tests/test_integration.py | 42 +++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index bf3bafc09..0d63b0b6b 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import datetime +import locale import os import unittest @@ -15,6 +16,8 @@ from zope.interface import Interface # 5 years from now (more or less) fiveyrsfuture = datetime.datetime.utcnow() + datetime.timedelta(5*365) +defaultlocale = locale.getdefaultlocale()[1] + class INothing(Interface): pass @@ -76,23 +79,25 @@ class TestStaticAppBase(IntegrationBase): res = self.testapp.get('/static/.hiddenfile', status=200) _assertBody(res.body, os.path.join(here, 'fixtures/static/.hiddenfile')) - def test_highchars_in_pathelement(self): - url = url_quote('/static/héhé/index.html') - res = self.testapp.get(url, status=200) - _assertBody( - res.body, - os.path.join(here, - text_('fixtures/static/héhé/index.html', 'utf-8')) - ) - - def test_highchars_in_filename(self): - url = url_quote('/static/héhé.html') - res = self.testapp.get(url, status=200) - _assertBody( - res.body, - os.path.join(here, - text_('fixtures/static/héhé.html', 'utf-8')) - ) + if defaultlocale is not None: + # These tests are expected to fail on LANG=C systems + def test_highchars_in_pathelement(self): + url = url_quote('/static/héhé/index.html') + res = self.testapp.get(url, status=200) + _assertBody( + res.body, + os.path.join(here, + text_('fixtures/static/héhé/index.html', 'utf-8')) + ) + + def test_highchars_in_filename(self): + url = url_quote('/static/héhé.html') + res = self.testapp.get(url, status=200) + _assertBody( + res.body, + os.path.join(here, + text_('fixtures/static/héhé.html', 'utf-8')) + ) def test_not_modified(self): self.testapp.extra_environ = { @@ -611,5 +616,8 @@ def read_(filename): return val def _assertBody(body, filename): + if defaultlocale is None: + # If system locale does not have an encoding then default to utf-8 + filename = filename.encode('utf-8') assert(body.replace(b'\r', b'') == read_(filename)) -- cgit v1.2.3 From f5b9e9c6708e4176231c45f5e478d56bba4b42e6 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 24 Feb 2012 14:51:15 -0500 Subject: use paren-bracketed imports for modules from the same source --- pyramid/tests/test_authentication.py | 6 ++++-- pyramid/tests/test_encode.py | 6 ++++-- pyramid/tests/test_httpexceptions.py | 6 ++++-- pyramid/tests/test_integration.py | 8 +++++--- pyramid/tests/test_mako_templating.py | 6 ++++-- pyramid/tests/test_request.py | 14 +++++++++----- pyramid/tests/test_url.py | 12 ++++++++---- pyramid/tests/test_view.py | 6 ++++-- 8 files changed, 42 insertions(+), 22 deletions(-) diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py index 02bfa1fed..e513b9a48 100644 --- a/pyramid/tests/test_authentication.py +++ b/pyramid/tests/test_authentication.py @@ -1,7 +1,9 @@ import unittest from pyramid import testing -from pyramid.compat import text_ -from pyramid.compat import bytes_ +from pyramid.compat import ( + text_, + bytes_, + ) class TestCallbackAuthenticationPolicyDebugging(unittest.TestCase): def setUp(self): diff --git a/pyramid/tests/test_encode.py b/pyramid/tests/test_encode.py index ccc8f16e3..736ecb5b3 100644 --- a/pyramid/tests/test_encode.py +++ b/pyramid/tests/test_encode.py @@ -1,6 +1,8 @@ import unittest -from pyramid.compat import text_ -from pyramid.compat import native_ +from pyramid.compat import ( + text_, + native_, + ) class UrlEncodeTests(unittest.TestCase): def _callFUT(self, query, doseq=False): diff --git a/pyramid/tests/test_httpexceptions.py b/pyramid/tests/test_httpexceptions.py index 84485fadc..0061907ba 100644 --- a/pyramid/tests/test_httpexceptions.py +++ b/pyramid/tests/test_httpexceptions.py @@ -1,7 +1,9 @@ import unittest -from pyramid.compat import bytes_ -from pyramid.compat import text_ +from pyramid.compat import ( + bytes_, + text_, + ) class Test_exception_response(unittest.TestCase): def _callFUT(self, *arg, **kw): diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index 0d63b0b6b..85a68ab25 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -8,8 +8,10 @@ import unittest from pyramid.wsgi import wsgiapp from pyramid.view import view_config from pyramid.static import static_view -from pyramid.compat import text_ -from pyramid.compat import url_quote +from pyramid.compat import ( + text_, + url_quote, + ) from zope.interface import Interface @@ -616,7 +618,7 @@ def read_(filename): return val def _assertBody(body, filename): - if defaultlocale is None: + if defaultlocale is None: # pragma: no cover # If system locale does not have an encoding then default to utf-8 filename = filename.encode('utf-8') assert(body.replace(b'\r', b'') == read_(filename)) diff --git a/pyramid/tests/test_mako_templating.py b/pyramid/tests/test_mako_templating.py index 0726c5250..550c95312 100644 --- a/pyramid/tests/test_mako_templating.py +++ b/pyramid/tests/test_mako_templating.py @@ -2,8 +2,10 @@ import unittest from pyramid import testing -from pyramid.compat import text_ -from pyramid.compat import text_type +from pyramid.compat import ( + text_, + text_type, + ) class Base(object): def setUp(self): diff --git a/pyramid/tests/test_request.py b/pyramid/tests/test_request.py index 8a5215a2b..170ea5c97 100644 --- a/pyramid/tests/test_request.py +++ b/pyramid/tests/test_request.py @@ -1,11 +1,15 @@ import unittest from pyramid import testing -from pyramid.compat import PY3 -from pyramid.compat import text_ -from pyramid.compat import bytes_ -from pyramid.compat import native_ -from pyramid.compat import iteritems_, iterkeys_, itervalues_ +from pyramid.compat import ( + PY3, + text_, + bytes_, + native_, + iteritems_, + iterkeys_, + itervalues_, + ) class TestRequest(unittest.TestCase): def setUp(self): diff --git a/pyramid/tests/test_url.py b/pyramid/tests/test_url.py index 7b05368ce..527bf31bc 100644 --- a/pyramid/tests/test_url.py +++ b/pyramid/tests/test_url.py @@ -1,10 +1,14 @@ import unittest import warnings -from pyramid.testing import setUp -from pyramid.testing import tearDown -from pyramid.compat import text_ -from pyramid.compat import native_ +from pyramid.testing import ( + setUp, + tearDown, + ) +from pyramid.compat import ( + text_, + native_, + ) class TestURLMethodsMixin(unittest.TestCase): def setUp(self): diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py index a775e7bc9..a105adb70 100644 --- a/pyramid/tests/test_view.py +++ b/pyramid/tests/test_view.py @@ -3,8 +3,10 @@ import sys from zope.interface import implementer -from pyramid.testing import setUp -from pyramid.testing import tearDown +from pyramid.testing import ( + setUp, + tearDown, + ) class BaseTest(object): def setUp(self): -- cgit v1.2.3