@v7C d dl mZ d dlZd dlmZmZ d dlmZ G d de Z G d de Z G d d e Z G d de Z G d de ZdS ) )TestCaseN)Draft4Validator exceptions)PY3c D e Zd Zd Zd Zd Zd Zd Zd Zd Z d Z d Zd S ) TestBestMatchc 2 t | }t j | }t j t | }d}| | | | || |S )Nz:Didn't return a consistent best match! Got: {0} Then: {1})msg)listr best_matchreversedassertEqual _contentsformat)selferrorsbest reversed_bestr s /builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/jsonschema/tests/test_exceptions.pyr zTestBestMatch.best_match s f$V,,"-hv.>.>?? MNNm5577 4// c t ddddddiidii }| | ddg ii }| |j d d S ) N propertiesfoo bartypeobject) minPropertiesr r r r iter_errorsr validatorr r! r s r (test_shallower_errors_are_better_matchesz6TestBestMatch.test_shallower_errors_are_better_matches s #)*',vx.@&A y44eeR[5IJJKK99999r c t dddiddigddiddigd }| | i }| |j d dS )zn A property you *must* match is probably better than one you have to match a part of. r r stringnumber)r anyOfoneOfr Nr r" s r %test_oneOf_and_anyOf_are_weak_matchesz3TestBestMatch.test_oneOf_and_anyOf_are_weak_matches" s $!"!8,vx.@A!8,vx.@A y44R889999999r c t dddddiddddiiigiii }| | dddii }| |j d d S ) aL If the most relevant error is an anyOf, then we traverse its context and select the otherwise *least* relevant error, since in this case that means the most specific, deep, error inside the instance. I.e. since only one of the schemas must match, we look for the most relevant one. r r r' r r% r array Nr r r r validator_valuer" s r 8test_if_the_most_relevant_error_is_anyOf_it_is_traversedzFTestBestMatch.test_if_the_most_relevant_error_is_anyOf_it_is_traversed2 $#X.)EFG3D+EF" y44eeR[5IJJKK-w77777r c t dddddiddddiiigiii }| | dddii }| |j d d S ) aL If the most relevant error is an oneOf, then we traverse its context and select the otherwise *least* relevant error, since in this case that means the most specific, deep, error inside the instance. I.e. since only one of the schemas must match, we look for the most relevant one. r r r( r r% r r+ r, Nr- r" s r 8test_if_the_most_relevant_error_is_oneOf_it_is_traversedzFTestBestMatch.test_if_the_most_relevant_error_is_oneOf_it_is_traversedK r0 r c t dddddiddddiiigiii }| | dddii }| |j d d S ) z Now, if the error is allOf, we traverse but select the *most* relevant error from the context, because all schemas here must match anyways. r r allOfr r% r r+ r, Nr- r" s r 8test_if_the_most_relevant_error_is_allOf_it_is_traversedzFTestBestMatch.test_if_the_most_relevant_error_is_allOf_it_is_traversedd s $#X.)EFG3D+EF" y44eeR[5IJJKK-x88888r c t dddddidddiddddiiigigiii }| | dddii }| |j d d S ) Nr r r( r r% r r+ r, r- r" s r test_nested_context_for_oneOfz+TestBestMatch.test_nested_context_for_oneOfy s ##X. '%+X$6(4,1FG3D7*%&*" " * y44eeR[5IJJKK-w77777r c t ddi }| i \ }| t j | i j d d S )Nr r )r r r r r r! )r r! errors r test_one_errorzTestBestMatch.test_one_error sm #_a$899 &&r**!)"7"7";";<<F r c t i }| t j | i d S )N)r assertIsNoner r r )r r! s r test_no_errorszTestBestMatch.test_no_errors sB #B'' */ 0E0Eb0I0IJJKKKKKr N)__name__ __module____qualname__r r# r) r/ r2 r5 r7 r: r= r r r r s : : :: : : 8 8 828 8 829 9 9*8 8 82 L L L L Lr r c &