Skip to content

Commit

Permalink
Merge pull request #74 from miguelgfierro/bug/flask
Browse files Browse the repository at this point in the history
Bug in flask due to bracking change in python 3.9+
  • Loading branch information
miguelgfierro committed Sep 14, 2023
2 parents 7257d0b + 45651cf commit 2e3af9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr_gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
fail-fast: false
max-parallel: 20 # Usage limits: https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration
matrix:
os: [macos-latest, ubuntu-18.04, ubuntu-20.04, ubuntu-22.04] # Available images: https://github.com/actions/runner-images/#available-images
python: ['3.7', '3.8', '3.9', '3.10']
os: [macos-latest, ubuntu-20.04, ubuntu-22.04] # Available images: https://github.com/actions/runner-images/#available-images
python: ["3.7", "3.8", "3.9", "3.10"]
steps:
- name: Checkout
uses: actions/checkout@v3 # Info: https://github.com/actions/checkout
Expand Down
13 changes: 6 additions & 7 deletions api/flask_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def post_status():
{
"message": "Param = 1"
}
Examples:
>>> with app.test_client() as c:
... headers = {"Content-type":"application/json"}
Expand Down Expand Up @@ -60,17 +60,16 @@ def bad_request(error):
False
$ res.json()
{u"error": u"Bad request"}
Examples:
>>> with app.test_client() as c:
... data = {"param":"2"}
... rv = c.post("/api/v1/post_json", data=json.dumps(data))
... status = rv.status
... content = rv.data.decode('utf8')
>>> status
'400 BAD REQUEST'
>>> json.loads(content)
{'error': 'Bad request'}
>>> # In Python 3.8, the status should be '400 BAD REQUEST'
>>> # In Python 3.9+, the status should be '415 UNSUPPORTED MEDIA TYPE'
>>> status # doctest: +SKIP
"""
return make_response(jsonify({"error": "Bad request"}), BAD_REQUEST)

Expand All @@ -84,7 +83,7 @@ def not_found(error):
False
$ res.json()
{u"error": u"Not found"}
Examples:
>>> with app.test_client() as c:
... headers = {"Content-type":"application/json"}
Expand Down

0 comments on commit 2e3af9c

Please sign in to comment.