Uo] d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlZd dl Z
d dlmZm
Z
mZmZ ej d Zd Zej d Zdd Zd
edefdZdedefd
Z G d d Zde
j j defdZdS ) N)Path)ListUnion)shorten_pathget_valid_filename_pytest_expected_on_rightflatten_filesystem_dictz^.*?\[(.*)]$c | d }| ddd | ddd d S )Nsnapshotz--snapshot-update
store_truez6Update snapshot files instead of testing against them.)actionhelpz--allow-snapshot-deletionz0Allow snapshot deletion when updating snapshots.)getgroup addoption)parsergroups h/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pytest_snapshot/plugin.pypytest_addoptionr sg OOJ''E OO
E
OO#
? c # K t | j }t | j j j | j j j | 5 }|V d d d d S # 1 swxY w Y d S N)_get_default_snapshot_dirnodeSnapshotconfigoptionsnapshot_updateallow_snapshot_deletion)requestdefault_snapshot_dirr s r r r s 4W\BB '.'7.'?&
(
( +3 s AAAreturnc F t r
| |k sJ d S || k sJ d S r )r )valuer s r
_assert_equalr$ ' s> "" ! 5 r stringc d| v rt d | dt j S )z
Returns the bytes that would be in a file created using ``path.write_text(string)``.
See universal newlines documentation.
aN Snapshot testing strings containing "\r" is not supported.
To snapshot test non-standard newlines you should convert the tested value to bytes.
Warning: git may decide to modify the newlines in the snapshot file.
To avoid this read https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
)
ValueErrorreplaceoslinesepencode)r% s r _file_encoder. . sL
v~~ j k k k >>$
++22444r datac z | dd dd S )z
Returns the string that would be read from a file using ``path.read_text(string)``.
See universal newlines documentation.
z
r( r' )decoder* )r/ s r _file_decoder2 > s2
;;== ..66tTBBBr c e Zd ZdZdZdZdZdZdZde de de
fdZd Zd Z
ed Zej d Zd
eee
f de
fdZd
eeef fdZd
eeef d
eee
f fdZdedeee
f fdZdS )r Nr r snapshot_dirc Z || _ || _ || _ g | _ g | _ g | _ d S r )_snapshot_update_allow_snapshot_deletionr4 _created_snapshots_updated_snapshots_snapshots_to_delete)selfr r r4 s r __init__zSnapshot.__init__N s8 /(?%("$"$$&!!!r c | S r r; s r __enter__zSnapshot.__enter__V s r c j s j s j rUd t j dg} j r;| d | fd j D j r;| d | fd j D j rv j r4 j D ]}| | d n| d | fd j D t j d
| d d S d S )
Nz#Snapshot directory was modified: {}zR (verify that the changes are expected before committing them to version control)z Created snapshots:c 3 l K | ].}d t | j z V /dS z Nstrrelative_tor4 .0sr; s r