Skip to content

Commit

Permalink
Fix encoding issues by making the code utf-8 encoded (Fix #40)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasbrunialti authored and jcfr committed Jan 31, 2018
1 parent 50af996 commit 949cb88
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 6 deletions.
7 changes: 4 additions & 3 deletions github_release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

from __future__ import print_function

Expand Down Expand Up @@ -370,7 +371,7 @@ def patch_release(repo_name, current_tag_name, **values):
response = _request(
'PATCH', url,
data=json.dumps(data),
headers={'Content-Type': 'application/json'})
headers={'Content-Type': 'application/json; charset=utf-8'})
response.raise_for_status()

# In case a new tag name was provided, remove the old one.
Expand Down Expand Up @@ -456,7 +457,7 @@ def gh_release_create(repo_name, tag_name, asset_pattern=None, name=None,
response = _request(
'POST', GITHUB_API + '/repos/{0}/releases'.format(repo_name),
data=json.dumps(data),
headers={'Content-Type': 'application/json'})
headers={'Content-Type': 'application/json; charset=utf-8'})
response.raise_for_status()
print_release_info(response.json(),
title="created '%s' release" % tag_name)
Expand Down Expand Up @@ -983,7 +984,7 @@ def gh_ref_create(repo_name, reference, sha):
response = _request(
'POST', GITHUB_API + '/repos/{0}/git/refs'.format(repo_name),
data=json.dumps(data),
headers={'Content-Type': 'application/json'})
headers={'Content-Type': 'application/json; charset=utf-8'})
response.raise_for_status()
print_ref_info(response.json())

Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

import datetime as dt
import errno
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

import os

Expand Down
3 changes: 2 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

import pytest

Expand Down Expand Up @@ -50,7 +51,7 @@
([], "release", "edit", ["1.0.0", "--tag-name", "new_tag",
"--target-commitish", "1234567",
"--name", "new_name",
"--body", "new_body"]),
"--body", u"new_body with utf-8 char …"]),
([], "release", "delete", ["1.0.0"]),
([], "release", "delete", ["*a", "--keep-pattern", "1*"]),
([], "release", "publish", ["1.0.0"]),
Expand Down
1 change: 1 addition & 0 deletions tests/test_distribution.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/test_integration_asset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import (
check_releases,
Expand Down
1 change: 1 addition & 0 deletions tests/test_integration_commit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import (
do_commit,
Expand Down
1 change: 1 addition & 0 deletions tests/test_integration_ref.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import (
do_commit,
Expand Down
1 change: 1 addition & 0 deletions tests/test_integration_release_create.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import (
check_releases,
Expand Down
1 change: 1 addition & 0 deletions tests/test_integration_release_delete.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import (
check_releases,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_integration_release_edit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

import pytest

Expand Down Expand Up @@ -137,15 +138,15 @@ def test_edit_name_and_body(release_type):
# Edit release
ghr.gh_release_edit(
REPO_NAME, "0.1.0",
name="name-edited", body="body-edited"
name="name-edited", body=u"body-edited with utf-8 char …"
)

assert (check_releases([
{"tag_name": "0.1.0",
"draft": params["draft"],
"prerelease": params["prerelease"],
"name": "name-edited",
"body": "body-edited"},
"body": u"body-edited with utf-8 char …"},
]))


Expand Down

0 comments on commit 949cb88

Please sign in to comment.