From de24338dd49915b23a0779c9f95fb880548a2da2 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 13:33:57 +0530 Subject: [PATCH 01/17] Update __init__.py --- Lib/venv/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py index 19eddde700bcf9..21f82125f5a7c4 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -581,7 +581,7 @@ def skip_file(f): 'may be binary: %s', srcfile, e) continue if new_data == data: - shutil.copy2(srcfile, dstfile) + shutil.copy(srcfile, dstfile) else: with open(dstfile, 'wb') as f: f.write(new_data) From ec2958bcd328ca2f8393953c11991d4cd4bb9895 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 15:18:39 +0530 Subject: [PATCH 02/17] Implement test for script installation mtime Add a test to verify mtime behavior during script installation. --- Lib/test/test_venv.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 68bcf535eada10..d0291f7bb026c2 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -373,6 +373,38 @@ def create_contents(self, paths, filename): with open(fn, 'wb') as f: f.write(b'Still here?') + def test_install_scripts_mtime(self): + """ + Test that install_scripts does not preserve mtime when copying scripts. + Using mtime serves as a proxy to verify that shutil.copy2 (and thus + SELinux bin_t contexts) is not being used during script installation. + """ + import time + from unittest.mock import patch + + builder = venv.EnvBuilder() + builder.create(self.env_dir) + context = builder.ensure_directories(self.env_dir) + + with tempfile.TemporaryDirectory() as script_dir: + common_dir = os.path.join(script_dir, 'common') + os.mkdir(common_dir) + script_path = os.path.join(common_dir, 'test_script.sh') + + with open(script_path, 'wb') as f: + f.write(b'echo Hello') + + past_time = time.time() - 10_000_000 + os.utime(script_path, (past_time, past_time)) + + builder.install_scripts(context, script_dir) + + dst_path = os.path.join(context.bin_path, 'test_script.sh') + self.assertTrue(os.path.exists(dst_path)) + + new_mtime = os.path.getmtime(dst_path) + self.assertGreater(new_mtime, past_time + 1000) + def test_overwrite_existing(self): """ Test creating environment in an existing directory. From 1428e7539e7f012b4cd2655e948c06b72f711e56 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 15:29:51 +0530 Subject: [PATCH 03/17] Relint test_venv.py and fix trailing whitespace Address linting failures in the new test_install_scripts_mtime by removing redundant imports and fixing trailing whitespace in the docstrings. --- Lib/test/test_venv.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index d0291f7bb026c2..5bac9f24e837fa 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -376,32 +376,31 @@ def create_contents(self, paths, filename): def test_install_scripts_mtime(self): """ Test that install_scripts does not preserve mtime when copying scripts. - Using mtime serves as a proxy to verify that shutil.copy2 (and thus + Using mtime serves as a proxy to verify that shutil.copy2 (and thus SELinux bin_t contexts) is not being used during script installation. """ import time - from unittest.mock import patch - + builder = venv.EnvBuilder() builder.create(self.env_dir) context = builder.ensure_directories(self.env_dir) - + with tempfile.TemporaryDirectory() as script_dir: common_dir = os.path.join(script_dir, 'common') os.mkdir(common_dir) script_path = os.path.join(common_dir, 'test_script.sh') - + with open(script_path, 'wb') as f: f.write(b'echo Hello') - + past_time = time.time() - 10_000_000 os.utime(script_path, (past_time, past_time)) - + builder.install_scripts(context, script_dir) - + dst_path = os.path.join(context.bin_path, 'test_script.sh') self.assertTrue(os.path.exists(dst_path)) - + new_mtime = os.path.getmtime(dst_path) self.assertGreater(new_mtime, past_time + 1000) From 87782097438925ea0bebdbbe5209c30d0a9ae3eb Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 16:29:53 +0530 Subject: [PATCH 04/17] Refine venv test to use Activate.ps1 and check mode (gh-145417) Update the mtime test case based on feedback --- Lib/test/test_venv.py | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 5bac9f24e837fa..1c10837498cd43 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -378,31 +378,41 @@ def test_install_scripts_mtime(self): Test that install_scripts does not preserve mtime when copying scripts. Using mtime serves as a proxy to verify that shutil.copy2 (and thus SELinux bin_t contexts) is not being used during script installation. + See gh-145417. """ import time - builder = venv.EnvBuilder() - builder.create(self.env_dir) - context = builder.ensure_directories(self.env_dir) + venv_dir = os.path.dirname(venv.__file__) + src_path = os.path.join(venv_dir, 'scripts', 'common', 'Activate.ps1') + src_mtime = os.path.getmtime(src_path) + if abs(time.time() - src_mtime) < 1.0: + time.sleep(1.1) + + rmtree(self.env_dir) + venv.create(self.env_dir) - with tempfile.TemporaryDirectory() as script_dir: - common_dir = os.path.join(script_dir, 'common') - os.mkdir(common_dir) - script_path = os.path.join(common_dir, 'test_script.sh') + dst_path = os.path.join(self.env_dir, self.bindir, 'Activate.ps1') + self.assertTrue(os.path.exists(dst_path), "Activate.ps1 not found in venv") + dst_mtime = os.path.getmtime(dst_path) - with open(script_path, 'wb') as f: - f.write(b'echo Hello') + # shutil.copy should update mtime, whereas shutil.copy2 would preserve it + self.assertNotEqual(src_mtime, dst_mtime, + "mtime was preserved, meaning shutil.copy2 was used") - past_time = time.time() - 10_000_000 - os.utime(script_path, (past_time, past_time)) + # Permissions and content should still match + src_stat = os.stat(src_path) + dst_stat = os.stat(dst_path) + self.assertEqual(src_stat.st_mode, dst_stat.st_mode, "File modes do not match") - builder.install_scripts(context, script_dir) + with open(src_path, 'rb') as f: + src_data = f.read() + with open(dst_path, 'rb') as f: + dst_data = f.read() + self.assertEqual(src_data, dst_data, "File contents do not match") - dst_path = os.path.join(context.bin_path, 'test_script.sh') - self.assertTrue(os.path.exists(dst_path)) + self.assertNotIn(b'__VENV_PYTHON__', src_data, + "Test assumes Activate.ps1 is a static file, not a template") - new_mtime = os.path.getmtime(dst_path) - self.assertGreater(new_mtime, past_time + 1000) def test_overwrite_existing(self): """ From 52ee5ef82403f4964fa95dcadbb3c3be4a00a7c9 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 16:48:26 +0530 Subject: [PATCH 05/17] Add news entry --- Misc/NEWS.d/next/Library/gh-145417.shrey.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/gh-145417.shrey.rst diff --git a/Misc/NEWS.d/next/Library/gh-145417.shrey.rst b/Misc/NEWS.d/next/Library/gh-145417.shrey.rst new file mode 100644 index 00000000000000..1408f230b4377b --- /dev/null +++ b/Misc/NEWS.d/next/Library/gh-145417.shrey.rst @@ -0,0 +1 @@ +gh-145417: Fixed venv to prevent incorrect preservation of SELinux contexts when copying scripts by using shutil.copy instead of shutil.copy2. From eec4e461a68cbf3ce691d790ba0ae11a8f797c69 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 16:51:52 +0530 Subject: [PATCH 06/17] Rename News --- .../Library/{gh-145417.shrey.rst => gh-issue-145417.shrey.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/Library/{gh-145417.shrey.rst => gh-issue-145417.shrey.rst} (100%) diff --git a/Misc/NEWS.d/next/Library/gh-145417.shrey.rst b/Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst similarity index 100% rename from Misc/NEWS.d/next/Library/gh-145417.shrey.rst rename to Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst From c4d32d52dc9a63782f4d722abd8f773ff959cf96 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 16:54:12 +0530 Subject: [PATCH 07/17] Delete Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst --- Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst diff --git a/Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst b/Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst deleted file mode 100644 index 1408f230b4377b..00000000000000 --- a/Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst +++ /dev/null @@ -1 +0,0 @@ -gh-145417: Fixed venv to prevent incorrect preservation of SELinux contexts when copying scripts by using shutil.copy instead of shutil.copy2. From 88fae45928e55ee2b06f1d291170fb6cf8dcefd7 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 16:57:26 +0530 Subject: [PATCH 08/17] Apply maintainer's suggestion for docstring clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miro Hrončok --- Lib/test/test_venv.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 1c10837498cd43..a4b34bfbab7884 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -376,8 +376,9 @@ def create_contents(self, paths, filename): def test_install_scripts_mtime(self): """ Test that install_scripts does not preserve mtime when copying scripts. - Using mtime serves as a proxy to verify that shutil.copy2 (and thus - SELinux bin_t contexts) is not being used during script installation. + Using mtime serves as a proxy to verify that shutil.copy2/copystat + is not used during script installation, + incorrectly copying e.g. SELinux bin_t context. See gh-145417. """ import time From 7dc69f0ba981d256f207269f94cb556832592aa5 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 17:03:59 +0530 Subject: [PATCH 09/17] Move template protection check before content assertion --- Lib/test/test_venv.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index a4b34bfbab7884..c917df6efa50e8 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -404,16 +404,20 @@ def test_install_scripts_mtime(self): src_stat = os.stat(src_path) dst_stat = os.stat(dst_path) self.assertEqual(src_stat.st_mode, dst_stat.st_mode, "File modes do not match") - + + self.assertNotIn(b'__VENV_PYTHON__', src_data, + "Test assumes Activate.ps1 is a static file, not a template") with open(src_path, 'rb') as f: src_data = f.read() - with open(dst_path, 'rb') as f: - dst_data = f.read() - self.assertEqual(src_data, dst_data, "File contents do not match") self.assertNotIn(b'__VENV_PYTHON__', src_data, "Test assumes Activate.ps1 is a static file, not a template") + with open(dst_path, 'rb') as f: + dst_data = f.read() + + self.assertEqual(src_data, dst_data, "File contents do not match") + def test_overwrite_existing(self): """ From 75bd9371a2c5fc1fd2f26e5f0248d38a5dbf25ef Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 17:11:23 +0530 Subject: [PATCH 10/17] Clean up blank lines in test_venv.py Removed unnecessary blank lines in the test case. --- Lib/test/test_venv.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index c917df6efa50e8..ba094a5607eaf2 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -404,18 +404,14 @@ def test_install_scripts_mtime(self): src_stat = os.stat(src_path) dst_stat = os.stat(dst_path) self.assertEqual(src_stat.st_mode, dst_stat.st_mode, "File modes do not match") - self.assertNotIn(b'__VENV_PYTHON__', src_data, "Test assumes Activate.ps1 is a static file, not a template") with open(src_path, 'rb') as f: src_data = f.read() - self.assertNotIn(b'__VENV_PYTHON__', src_data, "Test assumes Activate.ps1 is a static file, not a template") - with open(dst_path, 'rb') as f: dst_data = f.read() - self.assertEqual(src_data, dst_data, "File contents do not match") From a76da3ef47747b78baaaa415c272e8c3e4b4c2a8 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 17:18:22 +0530 Subject: [PATCH 11/17] Enhance test for Activate.ps1 file integrity Added a temporal check to ensure the source file is not modified during the test. Enhanced assertions to protect against future changes in the Activate.ps1 file's structure. --- Lib/test/test_venv.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index ba094a5607eaf2..da517e9c267e0c 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -386,6 +386,8 @@ def test_install_scripts_mtime(self): venv_dir = os.path.dirname(venv.__file__) src_path = os.path.join(venv_dir, 'scripts', 'common', 'Activate.ps1') src_mtime = os.path.getmtime(src_path) + + # Ensure a temporal difference between src and dst creation if abs(time.time() - src_mtime) < 1.0: time.sleep(1.1) @@ -404,14 +406,17 @@ def test_install_scripts_mtime(self): src_stat = os.stat(src_path) dst_stat = os.stat(dst_path) self.assertEqual(src_stat.st_mode, dst_stat.st_mode, "File modes do not match") - self.assertNotIn(b'__VENV_PYTHON__', src_data, - "Test assumes Activate.ps1 is a static file, not a template") + with open(src_path, 'rb') as f: src_data = f.read() + + # Protection against the file becoming a template in the future self.assertNotIn(b'__VENV_PYTHON__', src_data, "Test assumes Activate.ps1 is a static file, not a template") + with open(dst_path, 'rb') as f: dst_data = f.read() + self.assertEqual(src_data, dst_data, "File contents do not match") From 89c0c92750450baf4b4fb24cb8dfc13443ea7991 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:49:45 +0000 Subject: [PATCH 12/17] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst diff --git a/Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst b/Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst new file mode 100644 index 00000000000000..e6af3f08504386 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst @@ -0,0 +1 @@ +Fixed venv to prevent incorrect preservation of SELinux contexts when copying scripts by using shutil.copy instead of shutil.copy2. From 431c4ac5bac4244f7bc764baf9a77e6a0f3f096d Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 17:29:02 +0530 Subject: [PATCH 13/17] Applying maintainer's suggestion for news wording MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miro Hrončok --- .../next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst b/Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst index e6af3f08504386..100963c9252c09 100644 --- a/Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst +++ b/Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m_HxIL.rst @@ -1 +1 @@ -Fixed venv to prevent incorrect preservation of SELinux contexts when copying scripts by using shutil.copy instead of shutil.copy2. +Prevent incorrect preservation of SELinux context when copying scripts in :mod:`venv`. From 9bcf6db1059c047d05eb9a25f8d31be15077cb0d Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 17:41:00 +0530 Subject: [PATCH 14/17] Change Location of time module --- Lib/test/test_venv.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index da517e9c267e0c..85b4429d997dc3 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -14,6 +14,7 @@ import shutil import subprocess import sys +import time import sysconfig import tempfile import shlex @@ -381,8 +382,6 @@ def test_install_scripts_mtime(self): incorrectly copying e.g. SELinux bin_t context. See gh-145417. """ - import time - venv_dir = os.path.dirname(venv.__file__) src_path = os.path.join(venv_dir, 'scripts', 'common', 'Activate.ps1') src_mtime = os.path.getmtime(src_path) From 97652be17019e9866d1c3160cb77bb9ba97dfd93 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 3 Mar 2026 17:45:17 +0530 Subject: [PATCH 15/17] Reorder imports alphabetically MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miro Hrončok --- Lib/test/test_venv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 85b4429d997dc3..1945cb776ce446 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -11,13 +11,13 @@ import os.path import pathlib import re +import shlex import shutil import subprocess import sys -import time import sysconfig import tempfile -import shlex +import time from test.support import (captured_stdout, captured_stderr, skip_if_broken_multiprocessing_synchronize, verbose, requires_subprocess, is_android, is_apple_mobile, From 4e127d8893523adef65229c7f902ef7a4a72557a Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Thu, 5 Mar 2026 07:14:14 +0530 Subject: [PATCH 16/17] Refactor test for SELinux acc to suggestion --- Lib/test/test_venv.py | 50 ++++++------------------------------------- 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 1945cb776ce446..1722b17c3edd7d 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -374,50 +374,14 @@ def create_contents(self, paths, filename): with open(fn, 'wb') as f: f.write(b'Still here?') - def test_install_scripts_mtime(self): - """ - Test that install_scripts does not preserve mtime when copying scripts. - Using mtime serves as a proxy to verify that shutil.copy2/copystat - is not used during script installation, - incorrectly copying e.g. SELinux bin_t context. - See gh-145417. - """ - venv_dir = os.path.dirname(venv.__file__) - src_path = os.path.join(venv_dir, 'scripts', 'common', 'Activate.ps1') - src_mtime = os.path.getmtime(src_path) - - # Ensure a temporal difference between src and dst creation - if abs(time.time() - src_mtime) < 1.0: - time.sleep(1.1) - - rmtree(self.env_dir) + def test_install_scripts_selinux(self): + """ + gh-145417: Test that install_scripts does not copy SELinux context when + copying scripts. + """ + with patch('os.listxattr') as listxattr_mock: venv.create(self.env_dir) - - dst_path = os.path.join(self.env_dir, self.bindir, 'Activate.ps1') - self.assertTrue(os.path.exists(dst_path), "Activate.ps1 not found in venv") - dst_mtime = os.path.getmtime(dst_path) - - # shutil.copy should update mtime, whereas shutil.copy2 would preserve it - self.assertNotEqual(src_mtime, dst_mtime, - "mtime was preserved, meaning shutil.copy2 was used") - - # Permissions and content should still match - src_stat = os.stat(src_path) - dst_stat = os.stat(dst_path) - self.assertEqual(src_stat.st_mode, dst_stat.st_mode, "File modes do not match") - - with open(src_path, 'rb') as f: - src_data = f.read() - - # Protection against the file becoming a template in the future - self.assertNotIn(b'__VENV_PYTHON__', src_data, - "Test assumes Activate.ps1 is a static file, not a template") - - with open(dst_path, 'rb') as f: - dst_data = f.read() - - self.assertEqual(src_data, dst_data, "File contents do not match") - + listxattr_mock.assert_not_called() def test_overwrite_existing(self): """ From 0e506f110a4d294fd74a4f6d68db8f8896a5b924 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Thu, 5 Mar 2026 07:34:10 +0530 Subject: [PATCH 17/17] Fix SELinux context test and update patch usage --- Lib/test/test_venv.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 1722b17c3edd7d..c0f31a550f5263 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -375,13 +375,13 @@ def create_contents(self, paths, filename): f.write(b'Still here?') def test_install_scripts_selinux(self): - """ - gh-145417: Test that install_scripts does not copy SELinux context when - copying scripts. - """ - with patch('os.listxattr') as listxattr_mock: - venv.create(self.env_dir) - listxattr_mock.assert_not_called() + """ + gh-145417: Test that install_scripts does not copy SELinux context + when copying scripts. + """ + with patch('shutil.os.listxattr') as listxattr_mock: + venv.create(self.env_dir) + listxattr_mock.assert_not_called() def test_overwrite_existing(self): """