Your IP : 216.73.216.85
a
XC?h� � @ sh d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZ e� G dd� dej �Z
edkrde�� dS )� N)�support)�
scriptsdir�skip_if_missingc @ sT e Zd Zej�ed�Zdd� Zddd�Z dd � Z
d
d� Zdd
� Zdd� Z
dd� ZdS )�TestPathfixFunctionalz
pathfix.pyc C s | � tjtj� d S )N)�
addCleanupr �unlink�TESTFN��self� r �A/opt/alt/python39/lib64/python3.9/test/test_tools/test_pathfix.py�setUp s zTestPathfixFunctional.setUpr � c C s� |rt j�|d�}|}n
tj}|}t|ddd��$} | �|� d�d � W d � n1 sZ0 Y t�� }
t j
tj| jg|�d�|�i t j
�d|
i�d d
�}|dkr�|jdkr�|� d
�}| �|j||� | �|j�|
�|�dt j�|� | �|j�|
�|�dt j�|� t|ddd��} | �� }W d � n1 �s80 Y |�d�}
| �|
dd � ddg� |
d }|jdk�r�| �||� |S )Nz
script-A_1.py�w�utf8)�encoding�
zprint("Hello world")
z-nZPYTHONIOENCODINGT)�envZcapture_outputr r z: updating
�r� zprint("Hello world"))�os�path�joinr r �open�write�sys�getfilesystemencoding�
subprocess�run�
executable�script�environ�
returncode�assertEqual�stdout�decode�replace�linesep�stderr�read�split)r
ZshebangZ
pathfix_flags�exitcoder$ r( � directory�filenameZpathfix_arg�fr �proc�output�linesZnew_shebangr r r �pathfix s@ 2
����
(
zTestPathfixFunctional.pathfixc C sX t jd }| �t j|� t�|� dtj�|�� d�}| �| j dddg||d�d� d S ) Nz.dz
recursedown('z')
�#! /usr/bin/env python�-i�/usr/bin/python3)r, r( �#! /usr/bin/python3)
r r r Zrmtreer �mkdirr �basenamer# r2 )r
ZtmpdirZexpected_stderrr r r �test_recursive: s
��z$TestPathfixFunctional.test_recursivec C s4 | � | �dddg�d� | � | �dddg�d� d S )Nr3 r4 r5 r6 �#! /usr/bin/env python -R�r# r2 r r r r �test_pathfixG s ����z"TestPathfixFunctional.test_pathfixc C s4 | � | �dg d��d� | � | �dg d��d� d S )Nr: )r4 r5 �-kz#! /usr/bin/python3 -Rr3 r6 r; r r r r �test_pathfix_keeping_flagsS s ����z0TestPathfixFunctional.test_pathfix_keeping_flagsc C s| | � | �dg d��d� | � | �dg d��d� | � | �dg d��d� | � | �dg d��d � | � | �d
g d��d� d S )
Nr3 )r4 r5 �-a�sz#! /usr/bin/python3 -sz#! /usr/bin/env python -Sz#! /usr/bin/env python -V)r4 r5 r? �vr= z#! /usr/bin/python3 -vV)r4 r5 r? ZRsz#! /usr/bin/python3 -Rsz!#! /usr/bin/env python -W default)r4 r5 r? r@ r= z#! /usr/bin/python3 -sW defaultr; r r r r �test_pathfix_adding_flag_ sF ����������z.TestPathfixFunctional.test_pathfix_adding_flagc C s | j dg d�ddd� d S )Nz#! /usr/bin/env python -E)r4 r5 r? z W defaultr= � z%-a option doesn't support whitespaces)r+ r( )r2 r r r r �test_pathfix_adding_errorsz s �z0TestPathfixFunctional.test_pathfix_adding_errorsN)r r r r )�__name__�
__module__�__qualname__r r r r r r
r2 r9 r<