Skip to content

Commit

Permalink
test: add test for building with unicode filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
bpabel committed Jun 21, 2020
1 parent 5ed2484 commit 9185838
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
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 = "robin@camelot.uk"
home-page = "http://github.com/sirrobin/package2"
22 changes: 22 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

from pathlib import Path
import pytest
import shutil
Expand All @@ -12,6 +14,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 +72,22 @@ 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}
# -*- coding: utf-8 -*-
import sys
from os.path import join
if '--deleted' not in sys.argv:
files = ['pyproject.toml', 'packageunicode/__init__.py', 'packageunicode/Noël.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)]

0 comments on commit 9185838

Please sign in to comment.