File: //opt/cppython/lib/python3.8/test/test_tools/__pycache__/test_pathfix.cpython-38.opt-2.pyc
U
1D�g� � @ sl d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm Z e � G dd� dej
�Zedkrhe�
� dS )� N)�support)�import_tool�
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 �;/opt/cppython/lib/python3.8/test/test_tools/test_pathfix.py�setUp s zTestPathfixFunctional.setUpr � c C s& |rt j�|d�}|}n
tj}|}t|ddd��} | �|� d�d � W 5 Q R X tjt j
| jf|d|f�dd d
�}
|dkr�|
jdkr�|� d
�}| �
|
j||
� | �
|
j||
� | �
|
j||
� t|ddd��} | �� }W 5 Q R X |�d�}| �
|d d � ddg� |d }
|
jdk�r"| �
||
� |
S )Nz
script-A_1.py�w�utf8)�encoding�
zprint("Hello world")
z-nT� )�capture_output�textr r z: updating
�rzprint("Hello world"))�os�path�joinr r �open�write�
subprocess�run�sys�
executable�script�
returncode�assertEqual�stdout�stderr�read�split)r ZshebangZ
pathfix_flags�exitcoder$ r% � directory�filenameZpathfix_arg�f�proc�output�linesZnew_shebangr r r
�pathfix s:
� �
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 �rmtreer �mkdirr �basenamer# r/ )r ZtmpdirZexpected_stderrr r r
�test_recursive8 s
��z$TestPathfixFunctional.test_recursivec C s4 | � | �dddg�d� | � | �dddg�d� d S )Nr0 r1 r2 r3 �#! /usr/bin/env python -R�r# r/ r
r r r
�test_pathfixE s ����z"TestPathfixFunctional.test_pathfixc C s8 | � | �ddddg�d� | � | �ddddg�d� d S )Nr8 r1 r2 �-kz#! /usr/bin/python3 -Rr0 r3 r9 r
r r r
�test_pathfix_keeping_flagsQ s ����z0TestPathfixFunctional.test_pathfix_keeping_flagsc
C s� | � | �dddddg�d� | � | �dddddg�d� | � | �ddddd d
g�d� | � | �dddddg�d
� | � | �dddddd
g�d� d S )Nr0 r1 r2 �-a�sz#! /usr/bin/python3 -sz#! /usr/bin/env python -Sz#! /usr/bin/env python -V�vr; z#! /usr/bin/python3 -vVZRsz#! /usr/bin/python3 -Rsz!#! /usr/bin/env python -W defaultz#! /usr/bin/python3 -sW defaultr9 r
r r r
�test_pathfix_adding_flag] sF
��
����
����z.TestPathfixFunctional.test_pathfix_adding_flagc C s | j ddddddgddd � d S )
Nz#! /usr/bin/env python -Er1 r2 r= z W defaultr; � z%-a option doesn't support whitespaces)r( r% )r/ r
r r r
�test_pathfix_adding_errorsx s �z0TestPathfixFunctional.test_pathfix_adding_errorsN)r r r r )�__name__�
__module__�__qualname__r r r r r! r r/ r7 r: r<