Skip to content

Commit

Permalink
Merge pull request #225 from inklesspen/pyramid_version_tests
Browse files Browse the repository at this point in the history
Adds Pyramid version tests; bumps required version.
  • Loading branch information
mmerickel committed Jun 4, 2015
2 parents 92d6825 + 76d1098 commit c78f7c7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ env:
- TOXENV=py2-docs
- TOXENV=py3-docs
- TOXENV=py2-cover,py3-cover,coverage
- TOXENV=py27-pyramid14
- TOXENV=py27-pyramid15

install:
- travis_retry pip install tox
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ unreleased
executing queries with parameters that are not serializable.
See https://github.com/Pylons/pyramid_debugtoolbar/pull/227

- Adds Pyramid version tests and bumps required Pyramid version to 1.4.
The pyramid_mako dependency requires 1.3, but debugtoolbar also uses
invoke_subrequest which was added in 1.4. The invoke_subrequest call was added
in pyramid_debugtoolbar 2.0; if you need Pyramid 1.3 compatibility, try an older
version. See https://github.com/Pylons/pyramid_debugtoolbar/issues/183
and https://github.com/Pylons/pyramid_debugtoolbar/pull/225

2.3 (2015-01-05)
----------------

Expand Down
4 changes: 2 additions & 2 deletions pyramid_debugtoolbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ def populate(name):

return parsed

def set_request_authorization_callback(request, callback):
def set_request_authorization_callback(config, callback):
"""
Register IRequestAuthorization utility to authorize toolbar per request.
"""
request.registry.registerUtility(callback, IRequestAuthorization)
config.registry.registerUtility(callback, IRequestAuthorization)

def includeme(config):
""" Activate the debug toolbar; usually called via
Expand Down
3 changes: 3 additions & 0 deletions pyramid_debugtoolbar/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,15 @@ def toolbar_tween(request):
subrequest.path_info[len(request.script_name):]
response = request.invoke_subrequest(subrequest)

# The original request must be processed so that the panel data exists
# if the request is later examined in the full toolbar view.
toolbar.process_response(request, response)

toolbar.response = response
toolbar.status_int = response.status_int

request_history.put(request.pdtb_id, toolbar)
# Inject the button to activate the full toolbar view.
toolbar.inject(request, response)
return response
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
README = CHANGES = ''

install_requires = [
'pyramid>=1.2dev',
'pyramid>=1.4',
'pyramid_mako>=0.3.1', # lazy configuration loading works
'repoze.lru',
]
Expand Down
14 changes: 7 additions & 7 deletions tests/test_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_inject_html(self):
response = Response('<body></body>')
response.content_type = 'text/html'
request = Request.blank('/')
request.pdbt_id = 'abc'
request.pdtb_id = 'abc'
request.registry = self.config.registry
toolbar = self._makeOne(request, [DummyPanel], [DummyPanel], [])
toolbar.inject(request, response)
Expand All @@ -71,7 +71,7 @@ def test_passing_of_button_style(self):
response = Response('<body></body>')
response.content_type = 'text/html'
request = Request.blank('/')
request.pdbt_id = 'abc'
request.pdtb_id = 'abc'
request.registry = self.config.registry
toolbar = self._makeOne(request, [DummyPanel], [DummyPanel], [])
toolbar.inject(request, response)
Expand Down Expand Up @@ -252,7 +252,7 @@ def handler(request):
response = self._callFUT(request, handler, _logger=logger)
self.assertEqual(len(request.exc_history.tracebacks), 1)
self.assertFalse(hasattr(request, 'debug_toolbar'))
self.assertTrue(response.status_int, 500)
self.assertEqual(response.status_int, 500)

def test_it_intercept_redirect_nonredirect_code(self):
request = Request.blank('/')
Expand Down Expand Up @@ -287,7 +287,7 @@ def handler(request):
request.remote_addr = '127.0.0.1'
logger = DummyLogger()
response = self._callFUT(request, handler, _logger=logger)
self.assertTrue(response.status_int, 500)
self.assertEqual(response.status_int, 500)
self.assertTrue(
b'NotImplementedError: K\xc3\xa4se!\xe2\x98\xa0' in response.body or
# Python 3: the byte exception is escaped
Expand All @@ -307,7 +307,7 @@ def handler(request):
logger = DummyLogger()
response = self._callFUT(request, handler, _logger=logger)
self.assertFalse(hasattr(request, 'debug_toolbar'))
self.assertTrue(response.status_int, 500)
self.assertEqual(response.status_int, 500)

def test_show_on_exc_without_exc_raised(self):
request = Request.blank('/')
Expand All @@ -322,7 +322,7 @@ def handler(request):
request.registry = self.config.registry
request.remote_addr = '127.0.0.1'
response = self._callFUT(request, handler)
self.assertTrue(response.status_int, 200)
self.assertEqual(response.status_int, 200)
self.assertEqual(response.body, b"<html><body>OK!</body></html>")
self.assertFalse(hasattr(request, 'debug_toolbar'))

Expand All @@ -339,7 +339,7 @@ def handler(request):
request.registry = self.config.registry
request.remote_addr = '127.0.0.1'
response = self._callFUT(request, handler)
self.assertTrue(response.status_int, 200)
self.assertEqual(response.status_int, 200)
self.assertNotEqual(response.body, b"<html><body>OK!</body></html>")
self.assertFalse(hasattr(request, 'debug_toolbar'))

Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tox]
envlist =
py26,py27,py32,py33,py34,pypy,pypy3,
py27-pyramid{14,15},
{py2,py3}-docs,
{py2,py3}-cover,coverage

Expand All @@ -18,6 +19,10 @@ basepython =
py2: python2.7
py3: python3.4

deps =
pyramid14: pyramid <= 1.4.99
pyramid15: pyramid <= 1.5.99

commands =
pip install pyramid_debugtoolbar[testing]
nosetests --with-xunit --xunit-file=nosetests-{envname}.xml {posargs:}
Expand Down

0 comments on commit c78f7c7

Please sign in to comment.