Your IP : 216.73.216.213
�
g fC � @ sP d Z d d l Z d d l Z d d l Z e � Z Gd d � d e j � Z d S)zGbytecode_helper - support tools for testing correct bytecode generation� Nc @ s@ e Z d Z d Z d d � Z e d d � Z e d d � Z d S) �BytecodeTestCasez1Custom assertion methods for inspecting bytecode.c C s) t j � } t j | d | �| j � S)N�file)�io�StringIO�dis�getvalue)�self�co�s� r �9/opt/alt/python34/lib64/python3.4/test/bytecode_helper.py�get_disassembly_as_string s z*BytecodeTestCase.get_disassembly_as_stringc C s� xH t j | � D]7 } | j | k r | t k s@ | j | k rG | Sq q W| j | � } | t k ry d | | f } n d } | | | | f } | j | � d S)z=Returns instr if op is found, otherwise throws AssertionErrorz%s not found in bytecode:
%sz!(%s,%r) not found in bytecode:
%sN)r �get_instructions�opname�_UNSPECIFIED�argvalr
�fail)r �xr r �instr�disassembly�msgr r r �assertInBytecode s z!BytecodeTestCase.assertInBytecodec C s� x� t j | � D]~ } | j | k r | j t � } t t k rS d | | f } n+ | j | k r~ d } | | | | f } n | j | � q q Wd S)z$Throws AssertionError if op is foundz%s occurs in bytecode:
%sz(%s,%r) occurs in bytecode:
%sN) r r r r
r Zopargvalr r r )r r r r r r r r r r �assertNotInBytecode s z$BytecodeTestCase.assertNotInBytecodeN)�__name__�
__module__�__qualname__�__doc__r
r r r r r r r r s r )r Zunittestr r �objectr ZTestCaser r r r r �<module> s