File: D:/Python311/Lib/test/test_importlib/source/__pycache__/test_source_encoding.cpython-311.pyc
�
��Vc� � � � d dl mZ ej d� � Zd dlZd dlZd dlZd dlZd dl Z d dl
Z
d dlZ ej dej
� � Z G d� d� � Z G d� de� � Z ej ee� � � \ ZZ G d
� de� � Z ej ee� � � \ ZZ G d� d
� � Z G d� de� � Z ej ee� � � \ ZZ G d� de� � Z ej ee� � � \ ZZedk r e
j � � dS dS )� )�utilzimportlib.machineryNz&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)c � � e Zd ZdZdZdZd� ee� � ZdZd� Z d� Z
d� Zd � Zd
� Z
d� Zd� Zd
� Zd� ZdS )�EncodingTesta� PEP 3120 makes UTF-8 the default encoding for source code
[default encoding].
PEP 263 specifies how that can change on a per-file basis. Either the first
or second line can contain the encoding line [encoding first line]
[encoding second line]. If the file has the BOM marker it is considered UTF-8
implicitly [BOM]. If any encoding is specified it must be UTF-8, else it is
an error [BOM and utf-8][BOM conflict].
� ü� Éz{0} = '{1}'
�_tempc �x � t j | j � � 5 }t || j d� � 5 }|� |� � d d d � � n# 1 swxY w Y | j � | j || j � � }| � |� � cd d d � � S # 1 swxY w Y d S )N�wb)r �create_modules�module_name�open�write� machinery�SourceFileLoader�load)�self�source�mapping�file�loaders �CD:\Python311\Lib\test\test_importlib\source\test_source_encoding.py�run_testzEncodingTest.run_test% s+ � �
�
��!1�
2�
2� %�g��g�d�.�/��6�6�
#�$��
�
�6�"�"�"�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#����
#�
#�
#�
#��^�4�4�T�5E�29�$�:J�2K�M� M�F��9�9�V�$�$� %� %� %� %� %� %� %� %� %� %� %� %���� %� %� %� %� %� %s5 �B/�A�B/�A �B/�A � AB/�/B3�6B3c � � d� |� � }t � |� � sJ �|� d� � g}|� | j � |� � � � d� |� � S )Nz# coding={0}�utf-8�
)�format� CODING_RE�match�encode�append�source_line�join)r �encoding�
encoding_line�source_liness r �
create_sourcezEncodingTest.create_source- sz � �&�-�-�h�7�7�
����}�-�-�-�-�-�%�,�,�W�5�5�6�����D�,�3�3�H�=�=�>�>�>��z�z�,�'�'�'� c � � d}t � |� � sJ �d� |� � � d� � }| � |� � d S )Nz# coding=koi8-rz {0}
a=42
zkoi8-r)r r r r r )r r$ r s r �test_non_obvious_encodingz&EncodingTest.test_non_obvious_encoding4 sZ � � *�
����}�-�-�-�-�-��%�%�m�4�4�;�;�H�E�E���
�
�f�����r'