@@ -791,6 +791,57 @@ def test_venv_same_path(self):
791791 else :
792792 self .assertFalse (same_path (path1 , path2 ))
793793
794+ @requires_subprocess ()
795+ @unittest .skipIf (os .name == 'nt' , 'not relevant on Windows' )
796+ @unittest .skipUnless (can_symlink (), 'Needs symlinks' )
797+ def test_executable_symlink (self ):
798+ """
799+ Test creation using a symlink to python executable.
800+ """
801+ rmtree (self .env_dir )
802+ with tempfile .TemporaryDirectory () as symlink_dir :
803+ executable_symlink = os .path .join (
804+ os .path .realpath (symlink_dir ),
805+ os .path .basename (sys .executable ))
806+ os .symlink (os .path .abspath (sys .executable ), executable_symlink )
807+ cmd = [executable_symlink , "-m" , "venv" , "--without-pip" ,
808+ self .env_dir ]
809+ subprocess .check_call (cmd )
810+ data = self .get_text_file_contents ('pyvenv.cfg' )
811+ executable = sys ._base_executable
812+ path = os .path .dirname (executable )
813+ self .assertIn ('home = %s' % path , data )
814+ self .assertIn ('executable = %s' %
815+ os .path .realpath (sys .executable ), data )
816+
817+ @requires_subprocess ()
818+ @unittest .skipIf (os .name == 'nt' , 'not relevant on Windows' )
819+ @unittest .skipUnless (can_symlink (), 'Needs symlinks' )
820+ @requireVenvCreate
821+ def test_tree_symlink (self ):
822+ """
823+ Test creation using a symlink to python tree.
824+ """
825+ rmtree (self .env_dir )
826+ executable_abspath = os .path .abspath (sys ._base_executable )
827+ tree_abspath = os .path .dirname (os .path .dirname (executable_abspath ))
828+ with tempfile .TemporaryDirectory () as symlink_dir :
829+ tree_symlink = os .path .join (
830+ os .path .realpath (symlink_dir ),
831+ os .path .basename (tree_abspath ))
832+ executable_symlink = os .path .join (
833+ tree_symlink ,
834+ os .path .basename (os .path .dirname (executable_abspath )),
835+ os .path .basename (sys ._base_executable ))
836+ os .symlink (tree_abspath , tree_symlink )
837+ cmd = [executable_symlink , "-m" , "venv" , "--without-pip" ,
838+ self .env_dir ]
839+ subprocess .check_call (cmd )
840+ data = self .get_text_file_contents ('pyvenv.cfg' )
841+ self .assertIn ('home = %s' % tree_symlink , data )
842+ self .assertIn ('executable = %s' %
843+ os .path .realpath (sys ._base_executable ), data )
844+
794845@requireVenvCreate
795846class EnsurePipTest (BaseTest ):
796847 """Test venv module installation of pip."""
0 commit comments