ó
ŠwÛjc           @   s¤   d  Z  d d l Z d d l m Z m Z d d l m Z m Z e rh d d l Z d d l	 Z	 d „  Z
 n  d e j f d „  ƒ  YZ d „  Z e d	 k r  e ƒ  n  d S(
   s/   
   Test cases for codeop.py
   Nick Mathewson
iÿÿÿÿN(   t   run_unittestt	   is_jython(   t   compile_commandt   PyCF_DONT_IMPLY_DEDENTc         C   s:   x3 |  j  ƒ  D]% \ } } t | ƒ r t |  | <q q W|  S(   N(   t   itemst   callable(   t   dt   nt   v(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt   unify_callables   s    t   CodeopTestsc           B   sS   e  Z d  d „ Z d  d „ Z d  d d „ Z d „  Z d „  Z d „  Z d „  Z RS(	   t   singlec   	      B   s"  e  rí e | d | ƒ } |  j | ƒ | d k r† i  i  } } e j } e j ƒ  e _ z  | | Ue | d d ƒ | UWd | e _ XnH | d k rÎ i d d 6} i e | | ƒ d 6} i e | | ƒ d 6} n  |  j	 e
 | ƒ e
 | ƒ ƒ n1 e | d | e ƒ } |  j	 e | d | ƒ | ƒ d S(   s(   succeed iff str is a valid piece of codes   <input>R   Nt   evali   t   at   value(   R   R   t
   assertTruet   syst   stdoutt	   cStringIOt   StringIOt   compileR   t   assertEqualR	   R   (	   t   selft   strt   symbolt   codeR   t   rt   saved_stdoutt   ctxt   expected(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt   assertValid   s$    	c         C   s    |  j  t | d | ƒd ƒ d S(   s5   succeed iff str is the start of a valid piece of codeR   N(   R   R   t   None(   R   R   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt   assertIncomplete-   s    i   c         C   sd   y! t  | d | ƒ|  j d ƒ Wn< t k
 rA |  j | ƒ n t k
 r_ |  j | ƒ n Xd S(   s8   succeed iff str is the start of an invalid piece of codeR   s$   No exception raised for invalid codeN(   R   t   failt   SyntaxErrorR   t   OverflowError(   R   R   R   t	   is_syntax(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt   assertInvalid1   s    c         C   s  |  j  } t s\ |  j t d ƒ t d d d t ƒ ƒ |  j t d ƒ t d d d t ƒ ƒ n | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d	 ƒ | d
 ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d  d ƒ | d! d ƒ | d
 ƒ | d" ƒ | d ƒ | d# ƒ | d d ƒ | d  d ƒ | d! d ƒ | d$ ƒ | d% ƒ | d& ƒ d  S('   Nt    t   passs   <input>R   s   
s   a = 1s   
a = 1s   a = 1
s   a = 1

s	   

a = 1

s   def x():
  pass
s   if 1:
 pass
s   

if 1: pass
s   

if 1: pass

s   def x():

 pass
s   def x():
  pass
  
s   def x():
  pass
 
s   pass
s   3**3
s   if 9==3:
   pass
else:
   pass
s(   if 1:
 pass
 if 1:
  pass
 else:
  pass
s   #a
#b
a = 3
s   #a

   
a=3
s   a=3

s
   a = 9+ \
3s   3**3R   s   (lambda z: 
 z**3)s   9+ \
3s   9+ \
3
s   

a**3s   
 
a**3s
   #a
#b
a**3s   

if 1: a=1

s   #a

   
a=3

s1   def f():
 try: pass
 finally: [x for x in (1,2)]
s   def f():
 pass
#foo
s   @a.b.c
def f():
 pass
(   R   R   R   R   R   R   (   R   t   av(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt
   test_valid;   s^    	




























c         C   s  |  j  } | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d	 ƒ | d
 ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d  d ƒ | d! ƒ | d" ƒ | d# ƒ | d$ ƒ | d% ƒ | d& ƒ | d' ƒ | d( ƒ | d) ƒ | d* ƒ | d+ ƒ | d, ƒ | d- ƒ | d. ƒ | d/ ƒ | d0 ƒ | d1 ƒ | d2 ƒ | d3 ƒ | d4 ƒ | d5 ƒ | d6 ƒ | d7 ƒ | d8 ƒ | d9 ƒ | d: ƒ | d; ƒ | d< ƒ | d= ƒ | d> ƒ | d? ƒ | d@ ƒ | dA ƒ | dB ƒ | dC ƒ | dD ƒ | dE ƒ | dF ƒ | dG ƒ | dH ƒ | dI ƒ | dJ ƒ | d ƒ | dK ƒ | dL ƒ | dM ƒ | d ƒ | dN ƒ | dO ƒ | dP ƒ | dQ ƒ | dR ƒ | dS ƒ | dT ƒ | dU ƒ | dV ƒ | dW ƒ | dX ƒ | dY ƒ | dZ ƒ | d[ ƒ | d\ ƒ | d] ƒ | d^ ƒ | d_ ƒ | d` ƒ | da ƒ | db ƒ | dc ƒ | dd ƒ d  S(e   Ns   (a **s   (a,b,s   (a,b,(s   a = (s   a = {s   b + {s   if 9==3:
   pass
else:s   if 9==3:
   pass
else:
s   if 9==3:
   pass
else:
   passs   if 1:s   if 1:
s    if 1:
 pass
 if 1:
  pass
 else:s!   if 1:
 pass
 if 1:
  pass
 else:
s'   if 1:
 pass
 if 1:
  pass
 else:
  passs   def x():s	   def x():
s
   def x():

s   def x():
  passs   def x():
  pass
 s   def x():
  pass
  s   

def x():
  passs   a = 9+ \s   a = 'a\s	   a = '''xyR&   R   s   
t   (s   (


s   (9+s   9+ \s   lambda z: \s!   if True:
 if True:
  if True:   
s   @a(s   @a(bs   @a(b,s   @a(b,cs   @a(b,c,s   from a import (s   from a import (bs   from a import (b,s   from a import (b,cs   from a import (b,c,t   [s   [as   [a,s   [a,bs   [a,b,t   {s   {as   {a:s   {a:bs   {a:b,s   {a:b,cs   {a:b,c:s   {a:b,c:ds	   {a:b,c:d,s   a(s   a(bs   a(b,s   a(b,cs   a(b,c,s   a[s   a[bs   a[b,s   a[b:s   a[b:cs   a[b:c:s   a[b:c:ds   def a(s   def a(bs   def a(b,s	   def a(b,cs
   def a(b,c,s   (as   (a,s   (a,bs   if a:
 pass
elif b:s   if a:
 pass
elif b:
 pass
else:s   while a:s   while a:
 pass
else:s   for a in b:s   for a in b:
 pass
else:s   try:s   try:
 pass
except:s   try:
 pass
finally:s!   try:
 pass
except:
 pass
finally:s   with a:s   with a as b:s   class a:s   class a(s	   class a(bs
   class a(b,s
   class a():s   [x fors   [x for x ins   [x for x in (s   (x fors   (x for x ins   (x for x in ((   R    (   R   t   ai(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt   test_incomplete}   sÎ    	





























































































c         C   s3  |  j  } | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d	 ƒ | d
 ƒ | d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ d  S(   Ns   a bs   a @s   a b @s   a ** @s   a = s   a = 9 +s   def x():

pass
s   

 if 1: pass

passs	   a = 9+ \
s   a = 'a\ s   a = 'a\
s   a = 1R   s   a = (t   ]s   ())s   [}s   9+s	   lambda z:s
   return 2.3s   if (a == 1 and b = 2): passs   del 1s   del ()s   del (1,)s   del [1]s   del '1's"   [i for i in range(10)] = (1, 2, 3)(   R%   (   R   R-   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt   test_invalidý   s8    	

















c         C   sZ   |  j  t d d ƒ j t d d d ƒ j ƒ |  j t d d ƒ j t d d d ƒ j ƒ d  S(   Ns   a = 1
t   abcR   t   def(   R   R   t   co_filenameR   t   assertNotEqual(   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt   test_filename$  s    (	   t   __name__t
   __module__R   R    R%   R)   R.   R0   R5   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyR
      s   
	B	€	'c           C   s   t  t ƒ d  S(   N(   R    R
   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt	   test_main+  s    t   __main__(   t   __doc__t   unittestt   test.test_supportR    R   t   codeopR   R   R   R   R	   t   TestCaseR
   R8   R6   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_codeop.pyt   <module>   s   ÿ 	