Skip to content

Commit

Permalink
Merge pull request #766 from timothycrosley/develop
Browse files Browse the repository at this point in the history
Release 2.4.8
  • Loading branch information
timothycrosley authored Apr 7, 2019
2 parents 339ad7a + 9d7884c commit 63eaf8f
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.4.7
current_version = 2.4.8

[bumpversion:file:.env]

Expand Down
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

export PROJECT_NAME=$OPEN_PROJECT_NAME
export PROJECT_DIR="$PWD"
export PROJECT_VERSION="2.4.7"
export PROJECT_VERSION="2.4.8"

if [ ! -d "venv" ]; then
if ! hash pyvenv 2>/dev/null; then
Expand Down
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ matrix:
env: TOXENV=pypy3
- os: osx
language: generic
env: TOXENV=py34
env: TOXENV=py35
- os: osx
language: generic
env: TOXENV=py35
env: TOXENV=py36
- os: osx
language: generic
env: TOXENV=py37
before_install:
- "./scripts/before_install.sh"
install:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Ideally, within a virtual environment.
Changelog
=========

### 2.4.8 - April 7, 2019
- Fixed issue #762 - HTTP errors crash with selectable output types
- Fixed MacOS testing via travis - added testing accross all the same Python versions tested on Linux

### 2.4.7 - March 28, 2019
- Fixed API documentation with selectable output types

Expand Down
2 changes: 1 addition & 1 deletion hug/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
"""
from __future__ import absolute_import

current = "2.4.7"
current = "2.4.8"
3 changes: 2 additions & 1 deletion hug/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ def server(self, default_not_found=True, base_url=None):

def error_serializer(request, response, error):
response.content_type = self.output_format.content_type
response.body = self.output_format({"errors": {error.title: error.description}})
response.body = self.output_format({"errors": {error.title: error.description}},
request, response)

falcon_api.set_error_serializer(error_serializer)
return falcon_api
Expand Down
6 changes: 5 additions & 1 deletion scripts/before_install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/bash

echo $TRAVIS_OS_NAME

Expand All @@ -16,6 +16,10 @@ echo $TRAVIS_OS_NAME
python_minor=4;;
py35)
python_minor=5;;
py36)
python_minor=6;;
py37)
python_minor=7;;
esac
latest_version=`pyenv install --list | grep -e "^[ ]*3\.$python_minor" | tail -1`

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def list_modules(dirname):

setup(
name='hug',
version='2.4.7',
version='2.4.8',
description='A Python framework that makes developing APIs '
'as simple as possible, but no simpler.',
long_description=long_description,
Expand Down
20 changes: 20 additions & 0 deletions tests/test_output_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,26 @@ class FakeRequest(object):
assert formatter('hi', request, response) == b'"hi"'


def test_accept_with_http_errors():
"""Ensure that content type based output formats work for HTTP error responses"""
formatter = hug.output_format.accept({'application/json': hug.output_format.json,
'text/plain': hug.output_format.text},
default=hug.output_format.json)

api = hug.API('test_accept_with_http_errors')
hug.default_output_format(api=api)(formatter)

@hug.get('/500', api=api)
def error_500():
raise hug.HTTPInternalServerError('500 Internal Server Error',
'This is an example')

response = hug.test.get(api, '/500')
assert response.status == '500 Internal Server Error'
assert response.data == {
'errors': {'500 Internal Server Error': 'This is an example'}}


def test_suffix():
"""Ensure that it's possible to route the output type format by the suffix of the requested URL"""
formatter = hug.output_format.suffix({'.js': hug.output_format.json, '.html': hug.output_format.text})
Expand Down

0 comments on commit 63eaf8f

Please sign in to comment.