Current File : //lib/python3/dist-packages/twisted/logger/test/__pycache__/test_flatten.cpython-312.pyc |
�
Ϫ�f�% � � � d Z ddlZddlmZ ddlmZmZmZ ddlm Z ddlmZ ddl
mZmZmZmZ dd lmZ dd
lmZ G d� dej, � Zy# e
$ r dZ Y �=w xY w)
z+
Test cases for L{twisted.logger._format}.
� N)�count)�Any�Callable�Optional)�tzset)�unittest� )�KeyFlattener�
aFormatter�extractField�flattenEvent)�formatEvent)�LogEventc � � e Zd ZdZdd�Zdd�Zdd�Zdd�Z ddee de fd �Z
dd
�Zdd�Zdd�Z
d
� fdee ge f ddfd�Zdd�Zdd�Zdd�Zdd�Zy)�FlatFormattingTestsz9
Tests for flattened event formatting functions.
�returnNc � �� t � � G d� d� }t d�fd� |� ddd�� }t |� t |� }|d = |d
= t j t j
|� � }| j
t |� d� y)
a)
L{flattenEvent} will "flatten" an event so that, if scrubbed of all but
serializable objects, it will preserve all necessary data to be
formatted once serialized. When presented with an event thusly
flattened, L{formatEvent} will produce the same output.
c � � e Zd ZdZy)�;FlatFormattingTests.test_formatFlatEvent.<locals>.Ephemeral�valueN)�__name__�
__module__�__qualname__� attribute� � �B/usr/lib/python3/dist-packages/twisted/logger/test/test_flatten.py� Ephemeralr % s � ��Ir r z�callable: {callme()} attribute: {object.attribute} numrepr: {number!r} numstr: {number!s} strrepr: {string!r} unistr: {unistr!s}c � �� t � � S �N)�next��counters �r �<lambda>z:FlatFormattingTests.test_formatFlatEvent.<locals>.<lambda>1 s �� �4��=� r � �hello� ö)�
log_format�callme�object�number�string�unistrr) r* uM callable: 0 attribute: value numrepr: 7 numstr: 7 strrepr: 'hello' unistr: öN)r �dictr
�json�loads�dumps�assertEqualr )�selfr �event1�event2�event3r# s @r �test_formatFlatEventz(FlatFormattingTests.test_formatFlatEvent s� �� � �'�� � � �%� )��;����
�� �V���f����8���8�����D�J�J�v�.�/���������
r c �� � t dd�� }t |� t j t j |� � }| j t
|� j d� � y)zH
If the format string is invalid, an error is produced.
zstrrepr: {string!X}r&