File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -787,6 +787,20 @@ def test_scm_ignore_files_git(self):
787787 file_lines = self .get_text_file_contents ('.gitignore' ).splitlines ()
788788 self .assertIn ('*' , file_lines )
789789
790+ @requireVenvCreate
791+ def test_scm_ignore_files_git_appends_to_existing_file (self ):
792+ """Test that an existing .gitignore file is appended to."""
793+ gitignore_path = self .get_env_file ('.gitignore' )
794+ with open (gitignore_path , 'w' , encoding = 'utf-8' ) as fp :
795+ fp .write ("# Existing comment\n " )
796+
797+ self .run_with_capture (venv .create , self .env_dir ,
798+ scm_ignore_files = {'git' })
799+
800+ file_lines = self .get_text_file_contents ('.gitignore' ).splitlines ()
801+ self .assertIn ('# Existing comment' , file_lines )
802+ self .assertIn ('*' , file_lines )
803+
790804 @requireVenvCreate
791805 def test_create_scm_ignore_files_multiple (self ):
792806 """
Original file line number Diff line number Diff line change @@ -293,8 +293,8 @@ def create_git_ignore_file(self, context):
293293 ignored by git.
294294 """
295295 gitignore_path = os .path .join (context .env_dir , '.gitignore' )
296- with open (gitignore_path , 'w ' , encoding = 'utf-8' ) as file :
297- file .write ('# Created by venv; '
296+ with open (gitignore_path , 'a ' , encoding = 'utf-8' ) as file :
297+ file .write ('# Added by venv; '
298298 'see https://docs.python.org/3/library/venv.html\n ' )
299299 file .write ('*\n ' )
300300
You can’t perform that action at this time.
0 commit comments