B
    u9a<                 @   sT   d Z ddlmZ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rPe	  dS )	zDVerify that warnings are issued for global statements following use.    )run_unittest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errorz<test string>)module)r   _warnings_manager	__enter__warningsfilterwarnings)self r   !/usr/lib/python3.7/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   )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
z<test string>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   s.   t   t jddd tt W d Q R X d S )Nr   z<test string>)r   )r
   catch_warningsr   r   r   r   r   r   r   	test_main7   s    
r    __main__)__doc__Ztest.supportr   r   r   Zunittestr
   ZTestCaser   r    r   r   r   r   r   <module>   s   /