Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test for building with unicode filenames #355

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions tests/samples/packageunicode/packageunicode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Short Description
"""

__version__ = "1.0.0"
9 changes: 9 additions & 0 deletions tests/samples/packageunicode/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build-system]
requires = ["flit_core >=2,<4"]
build-backend = "flit_core.buildapi"

[tool.flit.metadata]
module = "packageunicode"
author = "Sir Robin"
author-email = "[email protected]"
home-page = "http://github.com/sirrobin/package2"
24 changes: 24 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

from pathlib import Path
import pytest
import shutil
Expand All @@ -12,6 +13,7 @@

LIST_FILES_TEMPLATE = """\
#!{python}
# -*- coding: utf-8 -*-
import sys
from os.path import join
if '--deleted' not in sys.argv:
Expand Down Expand Up @@ -69,3 +71,25 @@ def test_build_module_no_docstring():
with pytest.raises(common.NoDocstringError) as exc_info:
build.main(pyproject)
assert 'no_docstring.py' in str(exc_info.value)

def test_build_package_with_unicode(copy_sample):
list_files_template = """\
#!{python}
import sys
from os.path import join
if '--deleted' not in sys.argv:
files = ['pyproject.toml', 'packageunicode/__init__.py']
if sys.platform == 'win32':
files.append('packageunicode/No\\xc3\\xabl.jpg')
else:
files.append('packageunicode/No\\u00ebl.jpg')
print('\\0'.join(files), end='\\0')
"""
td = copy_sample('packageunicode')
(td / '.git').mkdir() # Fake a git repo

with MockCommand('git', list_files_template.format(python=sys.executable)):
res = build.main(td / 'pyproject.toml', formats={'sdist'})

# Compare str path to work around pathlib/pathlib2 mismatch on Py 3.5
assert [str(p) for p in (td / 'dist').iterdir()] == [str(res.sdist.file)]