@@ -892,6 +892,57 @@ def test_venvwlauncher(self):
892
892
except subprocess .CalledProcessError :
893
893
self .fail ("venvwlauncher.exe did not run %s" % exename )
894
894
895
+ @requires_subprocess ()
896
+ @unittest .skipIf (os .name == 'nt' , 'not relevant on Windows' )
897
+ @unittest .skipUnless (can_symlink (), 'Needs symlinks' )
898
+ def test_executable_symlink (self ):
899
+ """
900
+ Test creation using a symlink to python executable.
901
+ """
902
+ rmtree (self .env_dir )
903
+ with tempfile .TemporaryDirectory () as symlink_dir :
904
+ executable_symlink = os .path .join (
905
+ os .path .realpath (symlink_dir ),
906
+ os .path .basename (sys .executable ))
907
+ os .symlink (os .path .abspath (sys .executable ), executable_symlink )
908
+ cmd = [executable_symlink , "-m" , "venv" , "--without-pip" ,
909
+ self .env_dir ]
910
+ subprocess .check_call (cmd )
911
+ data = self .get_text_file_contents ('pyvenv.cfg' )
912
+ executable = sys ._base_executable
913
+ path = os .path .dirname (executable )
914
+ self .assertIn ('home = %s' % path , data )
915
+ self .assertIn ('executable = %s' %
916
+ os .path .realpath (sys .executable ), data )
917
+
918
+ @requires_subprocess ()
919
+ @unittest .skipIf (os .name == 'nt' , 'not relevant on Windows' )
920
+ @unittest .skipUnless (can_symlink (), 'Needs symlinks' )
921
+ @requireVenvCreate
922
+ def test_tree_symlink (self ):
923
+ """
924
+ Test creation using a symlink to python tree.
925
+ """
926
+ rmtree (self .env_dir )
927
+ executable_abspath = os .path .abspath (sys ._base_executable )
928
+ tree_abspath = os .path .dirname (os .path .dirname (executable_abspath ))
929
+ with tempfile .TemporaryDirectory () as symlink_dir :
930
+ tree_symlink = os .path .join (
931
+ os .path .realpath (symlink_dir ),
932
+ os .path .basename (tree_abspath ))
933
+ executable_symlink = os .path .join (
934
+ tree_symlink ,
935
+ os .path .basename (os .path .dirname (executable_abspath )),
936
+ os .path .basename (sys ._base_executable ))
937
+ os .symlink (tree_abspath , tree_symlink )
938
+ cmd = [executable_symlink , "-m" , "venv" , "--without-pip" ,
939
+ self .env_dir ]
940
+ subprocess .check_call (cmd )
941
+ data = self .get_text_file_contents ('pyvenv.cfg' )
942
+ self .assertIn ('home = %s' % tree_symlink , data )
943
+ self .assertIn ('executable = %s' %
944
+ os .path .realpath (sys ._base_executable ), data )
945
+
895
946
896
947
@requireVenvCreate
897
948
class EnsurePipTest (BaseTest ):
0 commit comments