3
SÉLjíô ã @ sÒ d Z ddlZddlZddlZddlZddlZyddlZW n ek
rT ddlZY nX ddl m
Z
ddl mZ ddl mZ ddl m
Z
ddl mZ ddl mZ dd l mZ dd
l mZ ddlmZ ddlmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ejZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZ G dd„ deƒZ!G dd„ deƒZ"G dd „ d eƒZ#G d!d"„ d"eƒZ$G d#d$„ d$eƒZ%G d%d&„ d&eƒZ&e'd'k�rÎej(ƒ dS )(ziUnittest for reflection.py, which also indirectly tests the output of the
pure-Python protocol compiler.
é N)Úunittest_import_pb2)Úunittest_mset_pb2)Úunittest_pb2)Údescriptor_pb2)Ú
descriptor)Úmessage)Ú
reflection)Útext_format)Úapi_implementation)Úmore_extensions_pb2)Úmore_messages_pb2)Úmessage_set_extensions_pb2)Úwire_format)Ú test_util)Útesting_refleaks)Údecoderc @ s\ e Zd ZdZdd„ Zdd„ ZeZeZeZeZ dd„ Z
e
Zdd „ Zd
d„ Z
dd
„ Zdd„ ZdS )Ú_MiniDecodera© Decodes a stream of values from a string.
Once upon a time we actually had a class called decoder.Decoder. Then we
got rid of it during a redesign that made decoding much, much faster overall.
But a couple tests in this file used it to check that the serialized form of
a message was correct. So, this class implements just the methods that were
used by said tests, so that we don't have to rewrite the tests.
c C s || _ d| _d S )Nr )Ú_bytesÚ_pos)ÚselfÚbytes© r ú%/usr/lib/python3.6/reflection_test.pyÚ__init__O s z_MiniDecoder.__init__c C s t j| j| jƒ\}| _|S )N)r Z
_DecodeVarintr r )r Úresultr r r Ú
ReadVarintS s z_MiniDecoder.ReadVarintc C s t j| jƒ ƒS )N)r ZZigZagDecoder )r r r r Ú
ReadSInt64\ s z_MiniDecoder.ReadSInt64c C s t j| jƒ ƒS )N)r Z UnpackTagr )r r r r ÚReadFieldNumberAndWireTypea s z'_MiniDecoder.ReadFieldNumberAndWireTypec C s4 t jd| j| j| jd … ƒd }| jd7 _|S )Nz