a
    ze^                     @   sN   d dl mZmZ d dlZd dlZG dd dejZdd ZedkrJe	  dS )    )check_syntax_errorcheck_warningsNc                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )GlobalTestsc                 C   s$   t  | _| j  tjddd d S Nerror<test string>)module)r   _warnings_manager	__enter__warningsfilterwarningsself r   &/usr/lib/python3.9/test/test_global.pysetUp
   s    
zGlobalTests.setUpc                 C   s   | j d d d  d S )N)r	   __exit__r   r   r   r   tearDown   s    zGlobalTests.tearDownc                 C   s   d}t | |ddd d S )Nz<def wrong1():
    a = 1
    b = 2
    global a
    global b
      linenooffsetr   )r   Zprog_text_1r   r   r   test1   s    zGlobalTests.test1c                 C   s   d}t | |ddd d S )Nz(def wrong2():
    print(x)
    global x
   r   r   r   )r   Zprog_text_2r   r   r   test2   s    zGlobalTests.test2c                 C   s   d}t | |ddd d S )Nz2def wrong3():
    print(x)
    x = 2
    global x
r   r   r   r   )r   Zprog_text_3r   r   r   test3%   s    zGlobalTests.test3c                 C   s   d}t |dd d S )Nzglobal x
x = 2
r   exec)compile)r   Zprog_text_4r   r   r   test4.   s    zGlobalTests.test4N)	__name__
__module____qualname__r   r   r   r   r   r    r   r   r   r   r      s   
	r   c                  C   s4   t  } |   t| jd d d  t jddd d S r   )r   catch_warningsr
   unittestZaddModuleCleanupr   r   )cmr   r   r   setUpModule7   s    r'   __main__)
Ztest.supportr   r   r%   r   ZTestCaser   r'   r!   mainr   r   r   r   <module>   s   /