test_archive_util.py 845 B

123456789101112131415161718192021222324252627282930313233343536
  1. import io
  2. import tarfile
  3. import pytest
  4. from setuptools import archive_util
  5. @pytest.fixture
  6. def tarfile_with_unicode(tmpdir):
  7. """
  8. Create a tarfile containing only a file whose name is
  9. a zero byte file called testimäge.png.
  10. """
  11. tarobj = io.BytesIO()
  12. with tarfile.open(fileobj=tarobj, mode="w:gz") as tgz:
  13. data = b""
  14. filename = "testimäge.png"
  15. t = tarfile.TarInfo(filename)
  16. t.size = len(data)
  17. tgz.addfile(t, io.BytesIO(data))
  18. target = tmpdir / 'unicode-pkg-1.0.tar.gz'
  19. with open(str(target), mode='wb') as tf:
  20. tf.write(tarobj.getvalue())
  21. return str(target)
  22. @pytest.mark.xfail(reason="#710 and #712")
  23. def test_unicode_files(tarfile_with_unicode, tmpdir):
  24. target = tmpdir / 'out'
  25. archive_util.unpack_archive(tarfile_with_unicode, str(target))