
    i#                        S SK r S SKJr  S SKJr  S SKJrJr  S SKJ	r
Jr  S SKJr  S SKJr  S SKJrJr  S S	KJrJr  S S
KJr  S SKJr  S SKJr  \" S\R@                  S9r! " S S5      r" " S S\"\RF                  5      r# " S S\"\RH                  5      r$ " S S\"\RJ                  5      r% " S S\"\RL                  5      r& " S S\"\RN                  5      r'\" 5       S\(\!   S\RR                  \-  S\RR                  \!   4S j5       r*\RV                  S 5       r,\" 5        S$S \(\
RZ                     S!\.S-  S\RR                  \-  S\RR                  \
RZ                     4S" jj5       r/\RV                  S# 5       r0g)%    N)partial)EllipsisType)AnyTypeVar)formstest)testing)ValidationError)IntegrityErrormodels)reject
strategies)InvalidArgument)
from_field)defines_strategyModelT)boundc                   *    \ rS rSrS rS rSS jrSrg)HypothesisTestCase   c                 $    U R                  5         g N)
_pre_setup)selfs    \/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/extra/django/_impl.pysetup_example HypothesisTestCase.setup_example   s        c                 $    U R                  5         g r   )_post_teardown)r   examples     r   teardown_example#HypothesisTestCase.teardown_example!   s    r   Nc                     [        X R                  5      n[        USS5      (       a  [        R                  R	                  X5      $ [
        R                  R	                  X5      $ )Nis_hypothesis_testF)getattr_testMethodNameunittestTestCase__call__dtSimpleTestCase)r   result
testMethods      r   r*   HypothesisTestCase.__call__$   sP    T#7#78
:3U;;$$--d;;$$--d;;r    r   )__name__
__module____qualname____firstlineno__r   r"   r*   __static_attributes__r0   r   r   r   r      s    <r   r   c                       \ rS rSrSrg)r,   ,   r0   Nr1   r2   r3   r4   r5   r0   r   r   r,   r,   ,       r   r,   c                       \ rS rSrSrg)r)   0   r0   Nr8   r0   r   r   r)   r)   0   r9   r   r)   c                       \ rS rSrSrg)TransactionTestCase4   r0   Nr8   r0   r   r   r=   r=   4   r9   r   r=   c                       \ rS rSrSrg)LiveServerTestCase8   r0   Nr8   r0   r   r   r@   r@   8   r9   r   r@   c                       \ rS rSrSrg)StaticLiveServerTestCase<   r0   Nr8   r0   r   r   rC   rC   <   r9   r   rC   modelfield_strategiesreturnc          	      4   [        U [        R                  5      (       d  [        SU < S35      eU R                  R
                   Vs0 s H  o"R                  U_M     nn[        UR                  5       5       H  u  pEUSL d  M  [        X4   5      X'   M     [        UR                  5       5       H  u  pFXA;  d  M  UR                  (       a  M  [        U[        R                  5      (       a  M@  [        U[        [        SS5      5      (       a  Mb  UR                  [        R                  R                   L d  M  [        U5      X'   M     U H  nU R                  R#                  U5      R$                  (       d  M/  XaR'                  U5      0n[(        R*                  " U5      US'   [-        [(        R.                  " U R0                  R2                  40 UD65      s  $    [-        [(        R.                  " U R0                  R4                  40 UD65      $ s  snf )a  Return a strategy for examples of ``model``.

.. warning::
    Hypothesis creates saved models. This will run inside your testing
    transaction when using the test runner, but if you use the dev console
    this will leave debris in your database.

``model`` must be an subclass of :class:`~django:django.db.models.Model`.
Strategies for fields may be passed as keyword arguments, for example
``is_staff=st.just(False)``.  In order to support models with fields named
"model", this is a positional-only parameter.

Hypothesis can often infer a strategy based the field type and validators,
and will attempt to do so for any required fields.  No strategy will be
inferred for an :class:`~django:django.db.models.AutoField`, nullable field,
foreign key, or field for which a keyword
argument is passed to ``from_model()``.  For example,
a Shop type with a foreign key to Company could be generated with::

    shop_strategy = from_model(Shop, company=from_model(Company))

Like for :func:`~hypothesis.strategies.builds`, you can pass
``...`` (:obj:`python:Ellipsis`) as a keyword argument to infer a strategy for
a field which has a default value instead of using the default.
zmodel=z must be a subtype of Model.GeneratedFieldr0   defaults)
issubclassdmModelr   _metaconcrete_fieldsnamesorteditemsr   auto_created
isinstance	AutoFieldr&   defaultfieldsNOT_PROVIDED	get_fieldprimary_keypopstfixed_dictionaries_models_implbuildsobjectsupdate_or_createget_or_create)rE   rF   ffields_by_namerP   valuefieldkwargss           r   
from_modelrh   @   s   : eRXX&&(CDEE).)D)DE)DAffai)DNE.4467C<%/0D%E" 8 n2245(&&&ubll33ugb2BB&GHH!7!77%/%6" 6 ";;  '333 11%89F!#!6!67G!HF:		%--*H*H SF STT " 		%--"="=RAQRSS5 Fs   Hc                 N     U " U5      S   $ ! [          a    [        5          gf = f)z5Handle the nasty part of drawing a value for models()r   N)r   r   drawstrats     r   r^   r^   }   s)    E{1~ s   
 $$formform_kwargsc           	         U=(       d    0 n[        U [        R                  5      (       d  [        SU < S35      eU " S0 UD6n0 nUR                  R                  5        HQ  u  pV[        U[        R                  5      (       a)  [        UR                  5       H  u  pxXU SU 3'   M     MM  XdU'   MS     [        UR                  5       5       H  u  pYU	SL d  M  [        XE   5      X%'   M     [        UR                  5       5       H,  u  pVXR;  d  M  UR                  (       a  M  [        U5      X%'   M.     0 n
0 nUR                  5        H0  u  pVXE   n[        U[        R                  5      (       a  UOU
nXmU'   M2     [        [        R                  " [!        U 40 UD6[        R"                  " U
5      [        R"                  " U5      S95      $ )a  Return a strategy for examples of ``form``.

``form`` must be an subclass of :class:`~django:django.forms.Form`.
Strategies for fields may be passed as keyword arguments, for example
``is_staff=st.just(False)``.

Hypothesis can often infer a strategy based the field type and validators,
and will attempt to do so for any required fields.  No strategy will be
inferred for a disabled field or field for which a keyword argument
is passed to ``from_form()``.

This function uses the fields of an unbound ``form`` instance to determine
field strategies, any keyword arguments needed to instantiate the unbound
``form`` instance can be passed into ``from_form()`` as a dict with the
keyword ``form_kwargs``. E.g.::

    shop_strategy = from_form(Shop, form_kwargs={"company_id": 5})

Like for :func:`~hypothesis.strategies.builds`, you can pass
``...`` (:obj:`python:Ellipsis`) as a keyword argument to infer a strategy for
a field which has a default value instead of using the default.
zform=z must be a subtype of Form_.)datafilesr0   )rK   dfBaseFormr   rW   rR   rT   MultiValueField	enumeraterQ   r   disabled	FileField_forms_implr\   r_   r   r]   )rm   rn   rF   unbound_formrd   rP   rf   i_fieldre   data_strategiesfile_strategies
form_field
dictionarys                 r   	from_formr      s   @ #KdBKK(('ABCC &+&LN#**002eR//00 'u||4	06$q}- 5 $)4  3  .4467C<%/0D%E" 8 n2245'%/%6" 6 ')O&(O'--/#)
)*bllCCO 	 !4 0 
		D(K(&&7''8	
 r   c                 H     U " U5      $ ! [          a    [        5          gf = f)z8Handle the nasty part of drawing a value for from_form()N)r
   r   rj   s     r   ry   ry      s%    E{ s   
 !!r   )1r(   	functoolsr   typesr   typingr   r   djangor   rs   r   r+   django.contrib.staticfilesr	   dstdjango.core.exceptionsr
   	django.dbr   r   rL   
hypothesisr   r   r\   hypothesis.errorsr   hypothesis.extra.django._fieldsr   %hypothesis.strategies._internal.utilsr   rM   r   r   r,   r)   r=   r@   rC   typeSearchStrategyrh   	compositer^   Formdictr   ry   r0   r   r   <module>r      s       * 5 2 2 / - 6 B		*< <	'):): 		!2;; 		,b.D.D 		+R-B-B 		133O3O 	 9T<9T020A0AL0P9Tv9T 9Tx     $V
rww-VV ))L8V rww	V Vr  r   