@@ -791,6 +791,54 @@ 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+ def test_tree_symlink (self ):
821+ """
822+ Test creation using a symlink to python tree.
823+ """
824+ rmtree (self .env_dir )
825+ tree_abspath = os .path .dirname (os .path .abspath (sys .executable ))
826+ with tempfile .TemporaryDirectory () as symlink_dir :
827+ tree_symlink = os .path .join (
828+ os .path .realpath (symlink_dir ),
829+ os .path .basename (tree_abspath ))
830+ executable_symlink = os .path .join (
831+ tree_symlink ,
832+ os .path .basename (sys .executable ))
833+ os .symlink (tree_abspath , tree_symlink )
834+ cmd = [executable_symlink , "-m" , "venv" , "--without-pip" ,
835+ self .env_dir ]
836+ subprocess .check_call (cmd )
837+ data = self .get_text_file_contents ('pyvenv.cfg' )
838+ self .assertIn ('home = %s' % tree_symlink , data )
839+ self .assertIn ('executable = %s' %
840+ os .path .realpath (sys .executable ), data )
841+
794842@requireVenvCreate
795843class EnsurePipTest (BaseTest ):
796844 """Test venv module installation of pip."""
0 commit comments