From efecaf8cdb7ca4623d2efd53590adf976fd36954 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 May 2016 15:06:59 -0400 Subject: Add test ref #261. --- setuptools/tests/test_build_py.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 setuptools/tests/test_build_py.py (limited to 'setuptools/tests/test_build_py.py') diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py new file mode 100644 index 00000000..ed1703ac --- /dev/null +++ b/setuptools/tests/test_build_py.py @@ -0,0 +1,31 @@ +import os + +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): + """ + Directories matching the glob in package_data should + not be included in the package data. + + Regression test for #261. + """ + dist = Distribution(dict( + script_name='setup.py', + script_args=['build_py'], + packages=[''], + name='foo', + package_data={'': ['path/*']}, + )) + os.makedirs('path/subpath') + #with contexts.quiet(): + dist.parse_command_line() + dist.run_commands() -- cgit v1.2.1 From f1e3a3fc4199c80e1eca7af0d1bd10544faf1542 Mon Sep 17 00:00:00 2001 From: stepshal Date: Wed, 13 Jul 2016 14:49:35 +0700 Subject: Format block comments. --- setuptools/tests/test_build_py.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_build_py.py') diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index ed1703ac..860c569c 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -26,6 +26,6 @@ def test_directories_in_package_data_glob(tmpdir_as_cwd): package_data={'': ['path/*']}, )) os.makedirs('path/subpath') - #with contexts.quiet(): + # with contexts.quiet(): dist.parse_command_line() dist.run_commands() -- cgit v1.2.1 From 39bcc16e47957bea4178a27f2ef872a78276ff40 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 14 Jul 2016 00:58:42 -0400 Subject: Remove commented code --- setuptools/tests/test_build_py.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/tests/test_build_py.py') diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index 860c569c..cc701ae6 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -26,6 +26,5 @@ def test_directories_in_package_data_glob(tmpdir_as_cwd): package_data={'': ['path/*']}, )) os.makedirs('path/subpath') - # with contexts.quiet(): dist.parse_command_line() dist.run_commands() -- cgit v1.2.1 From 3ac3b67e2c8a776f410eae49472a0f8266e29612 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 28 Jan 2019 23:04:09 +0100 Subject: tests: minor cleanup --- setuptools/tests/test_build_py.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'setuptools/tests/test_build_py.py') diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index cc701ae6..b3a99f56 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -1,17 +1,9 @@ import os -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. -- cgit v1.2.1 From 52e718872259617203556e4889d451167f209343 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 21 Mar 2020 06:28:17 -0400 Subject: Add test capturing expectation. Ref #1451. --- setuptools/tests/test_build_py.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'setuptools/tests/test_build_py.py') diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index b3a99f56..92b455dd 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -1,4 +1,6 @@ import os +import stat +import shutil from setuptools.dist import Distribution @@ -20,3 +22,28 @@ def test_directories_in_package_data_glob(tmpdir_cwd): os.makedirs('path/subpath') dist.parse_command_line() dist.run_commands() + + +def test_read_only(tmpdir_cwd): + """ + Ensure mode 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']}, + name='pkg', + )) + 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') -- cgit v1.2.1 From a3620a45b3df9be32316bd8807ca5a83c1380c9a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 25 Mar 2020 13:29:50 -0400 Subject: Add test asserting that an executable script retains its executable bit. Ref #2041. --- setuptools/tests/test_build_py.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'setuptools/tests/test_build_py.py') diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index 92b455dd..4cb11c1d 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -26,9 +26,10 @@ def test_directories_in_package_data_glob(tmpdir_cwd): def test_read_only(tmpdir_cwd): """ - Ensure mode is not preserved in copy for package modules - and package data, as that causes problems - with deleting read-only files on Windows. + 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 """ @@ -47,3 +48,29 @@ def test_read_only(tmpdir_cwd): dist.parse_command_line() dist.run_commands() shutil.rmtree('build') + + +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']}, + name='pkg', + )) + 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" -- cgit v1.2.1 From ef3a38644ccc9f65ea20493e25de0955695b9dff Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 25 Mar 2020 14:00:29 -0400 Subject: Mark test_executable_data as xfail on Windows. --- setuptools/tests/test_build_py.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'setuptools/tests/test_build_py.py') diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index 4cb11c1d..78a31ac4 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -2,6 +2,8 @@ import os import stat import shutil +import pytest + from setuptools.dist import Distribution @@ -50,6 +52,12 @@ def test_read_only(tmpdir_cwd): 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 -- cgit v1.2.1