aboutsummaryrefslogtreecommitdiff
path: root/setuptools/tests/test_build_py.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/tests/test_build_py.py')
-rw-r--r--setuptools/tests/test_build_py.py67
1 files changed, 59 insertions, 8 deletions
diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py
index cc701ae..19c8b78 100644
--- a/setuptools/tests/test_build_py.py
+++ b/setuptools/tests/test_build_py.py
@@ -1,17 +1,13 @@
import os
+import stat
+import shutil
import pytest
from setuptools.dist import Distribution
-@pytest.yield_fixture
-def tmpdir_as_cwd(tmpdir):
- with tmpdir.as_cwd():
- yield tmpdir
-
-
-def test_directories_in_package_data_glob(tmpdir_as_cwd):
+def test_directories_in_package_data_glob(tmpdir_cwd):
"""
Directories matching the glob in package_data should
not be included in the package data.
@@ -22,9 +18,64 @@ def test_directories_in_package_data_glob(tmpdir_as_cwd):
script_name='setup.py',
script_args=['build_py'],
packages=[''],
- name='foo',
package_data={'': ['path/*']},
))
os.makedirs('path/subpath')
dist.parse_command_line()
dist.run_commands()
+
+
+def test_read_only(tmpdir_cwd):
+ """
+ Ensure read-only flag is not preserved in copy
+ for package modules and package data, as that
+ causes problems with deleting read-only files on
+ Windows.
+
+ #1451
+ """
+ dist = Distribution(dict(
+ script_name='setup.py',
+ script_args=['build_py'],
+ packages=['pkg'],
+ package_data={'pkg': ['data.dat']},
+ ))
+ os.makedirs('pkg')
+ open('pkg/__init__.py', 'w').close()
+ open('pkg/data.dat', 'w').close()
+ os.chmod('pkg/__init__.py', stat.S_IREAD)
+ os.chmod('pkg/data.dat', stat.S_IREAD)
+ dist.parse_command_line()
+ dist.run_commands()
+ shutil.rmtree('build')
+
+
+@pytest.mark.xfail(
+ 'platform.system() == "Windows"',
+ reason="On Windows, files do not have executable bits",
+ raises=AssertionError,
+ strict=True,
+)
+def test_executable_data(tmpdir_cwd):
+ """
+ Ensure executable bit is preserved in copy for
+ package data, as users rely on it for scripts.
+
+ #2041
+ """
+ dist = Distribution(dict(
+ script_name='setup.py',
+ script_args=['build_py'],
+ packages=['pkg'],
+ package_data={'pkg': ['run-me']},
+ ))
+ os.makedirs('pkg')
+ open('pkg/__init__.py', 'w').close()
+ open('pkg/run-me', 'w').close()
+ os.chmod('pkg/run-me', 0o700)
+
+ dist.parse_command_line()
+ dist.run_commands()
+
+ assert os.stat('build/lib/pkg/run-me').st_mode & stat.S_IEXEC, \
+ "Script is not executable"