Skip to content

Commit

Permalink
Fix unicode tests on Python 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentzo committed Aug 14, 2018
1 parent 3d8df3f commit 3a4ed63
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test_git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from functools import partial
import os
from subprocess import check_call
from tarfile import TarFile
import sys
from tarfile import TarFile, PAX_FORMAT

import pycodestyle
import pytest
Expand Down Expand Up @@ -224,7 +225,7 @@ def test_ignore(contents, tmpdir, git_env):

repo_tar_path = os.path.join(str(tmpdir), 'repo.tar')
repo.archive(repo_tar_path)
repo_tar = TarFile(repo_tar_path)
repo_tar = TarFile(repo_tar_path, format=PAX_FORMAT, encoding='utf-8')

def make_expected(contents):
e = {}
Expand All @@ -243,7 +244,12 @@ def make_actual(tar_file):

for m in tar_file.getmembers():
if m.isfile():
a[m.name] = tar_file.extractfile(m).read().decode()
name = m.name

if sys.version_info < (3,):
name = m.name.decode('utf-8')

a[name] = tar_file.extractfile(m).read().decode()
else:
raise NotImplementedError

Expand Down

0 comments on commit 3a4ed63

Please sign in to comment.