mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	test_httpservers: Fix skip test check, the python executable path have to be
encodable to utf-8, not to the file1 encoding.
This commit is contained in:
		
							parent
							
								
									23d05c1d98
								
							
						
					
					
						commit
						3218c31429
					
				
					 1 changed files with 10 additions and 7 deletions
				
			
		| 
						 | 
					@ -310,15 +310,18 @@ def setUp(self):
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.pythonexe = sys.executable
 | 
					            self.pythonexe = sys.executable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            # The python executable path is written as the first line of the
 | 
				
			||||||
 | 
					            # CGI Python script. The encoding cookie cannot be used, and so the
 | 
				
			||||||
 | 
					            # path should be encodable to the default script encoding (utf-8)
 | 
				
			||||||
 | 
					            self.pythonexe.encode('utf-8')
 | 
				
			||||||
 | 
					        except UnicodeEncodeError:
 | 
				
			||||||
 | 
					            self.tearDown()
 | 
				
			||||||
 | 
					            raise self.skipTest(
 | 
				
			||||||
 | 
					                "Python executable path is not encodable to utf-8")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
 | 
					        self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
 | 
				
			||||||
        with open(self.file1_path, 'w') as file1:
 | 
					        with open(self.file1_path, 'w') as file1:
 | 
				
			||||||
            try:
 | 
					 | 
				
			||||||
                self.pythonexe.encode(file1.encoding)
 | 
					 | 
				
			||||||
            except UnicodeEncodeError:
 | 
					 | 
				
			||||||
                self.tearDown()
 | 
					 | 
				
			||||||
                raise self.skipTest(
 | 
					 | 
				
			||||||
                    "Python executable path is not encodable to %s"
 | 
					 | 
				
			||||||
                    % file1.encoding)
 | 
					 | 
				
			||||||
            file1.write(cgi_file1 % self.pythonexe)
 | 
					            file1.write(cgi_file1 % self.pythonexe)
 | 
				
			||||||
        os.chmod(self.file1_path, 0o777)
 | 
					        os.chmod(self.file1_path, 0o777)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue