Your IP : 216.73.216.196


Current Path : /opt/alt/python27/lib/python2.7/site-packages/hypothesis/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyc

�
�GHWc@`s�dZddlmZmZmZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZmZmZmZmZmZmZmZddlmZddlmZdd	lmZmZmZdd
lmZm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'dd
l(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2d�Z3d�Z4edddf�Z5d�Z6e7e7d�Z8d�Z9de2fd��YZ:d�Z;e<e<e<d�Z=dS(sIThis module provides the core primitives of Hypothesis, assume and given.i(tdivisiontprint_functiontabsolute_importN(tRandom(t
namedtuple(tFlakytTimeoutt
NoSuchExamplet
UnsatisfiabletInvalidArgumenttFailedHealthChecktUnsatisfiedAssumptiontHypothesisDeprecationWarning(tBuildContext(tsettings(tPhaset	VerbositytHealthCheck(tnew_style_executortdefault_new_style_executor(treporttverbose_reporttcurrent_verbosity(t
getargspectstr_to_bytes(tnicereprt
arg_stringtimpersonatetcopy_argspectfunction_digesttfully_qualified_nametconvert_positional_argumentstget_pretty_function_description(tSearchStrategycC`s"ddl}|j|jd��S(Nii�(trandomRtgetrandbits(R"((s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyt
new_random.sc`s"tj���fd��}|S(Nc`s/t�||�}td�j|f��dS(NsjHypothesis %s(%s) produces unreliable results: Falsified on the first call but did not on a subsequent one(RRt__name__(targstkwargst	text_repr(ttest(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyt
test_or_flaky4s(t	functoolstwraps(R)t
expected_reprR*((R)s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyt
test_is_flaky3stExampleR&R'c`sL�r�rtd��n�p$�s6td��n��fd�}|S(sJAdd an explicit example called with these args and kwargs to the
    test.s8Cannot mix positional and keyword arguments for exampless-An example must provide at least one argumentc`s>t|d�sg|_n|jjtt�����|S(Nthypothesis_explicit_examples(thasattrR0tappendR/ttuple(R)(R&R'(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytacceptNs(R	(R&R'R4((R&R's@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytexampleBsc`s/ddlm������fd�}|S(Ni(t
random_modulec`s�ddlm}td����|j���j}|dkrU|d|f�n|j��\���r�t���fd��n.t�tjkr�t���fd��n����SWdQXdS(Ni(tnotetis_finalsrandom.seed(%d)c`sd�jt����fS(NsFalsifying example: %s(%s)(R%R((R&R'R)(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyt<lambda>hsc`sd�jt����fS(NsTrying example: %s(%s)(R%R((R&R'R)(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9ls(	thypothesis.controlR7R
tdrawtseedRRRtverbose(tdataR7R<(R8t
print_exampleR6tsearch_strategyR)(R&R's@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytrun]s(thypothesis.strategiesR6(R@R)R?R8RA((R8R?R6R@R)s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytreify_and_executeVsc`s�fd�}|S(s�
    seed: Start the test execution from a specific seed. May be any hashable
          object. No exact meaning for seed is provided other than that
          for a fixed seed value Hypothesis will try the same actions (insofar
          as it can given external sources of non-determinism. e.g. timing and
          hash randomization).
          Overrides the derandomize setting if it is present.
    c`s
�|_|S(N(t_hypothesis_internal_use_seed(R)(R<(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR4|s	((R<R4((R<s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR<rs
t
WithRunnercB`seZd�Zd�ZRS(cC`s(|dk	st�||_||_dS(N(tNonetAssertionErrortbasetrunner(tselfRHRI((s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyt__init__�s	cC`s|j|_|jj|�S(N(RIthypothesis_runnerRHtdo_draw(RJR>((s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyRM�s(R%t
__module__RKRM(((s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyRE�s	c`s��fd�}|S(s�A decorator for turning a test function that accepts arguments into a
    randomized test.

    This is the main entry point to Hypothesis. See the full tutorial
    for details of its behaviour.

    c		`s�t���d�}�p�r/|d�Sn�oD�jpD�jrT|d�Snt��t�j�kr�|d�jt��t�j�f�Sn�o��r�|d�Sng�D]}|�jkr�|^q�}|o��jr
|d�j|df�Sn�j}x4|D],}t|t�rF|d�jf�SnqW�jr`|d	�Snx2t	|t����D]\}}|�|<q{Wt
jd
g|D]}|�kr�|^q�d�jd�jd
t��t
��t�j�������fd����xPt��D]B}|ddkoGt�|�rft�|t�|��nq$Wt�_t�dt��_t�dt�p�tj�_�S(Nc`s�fd�}|S(Nc`st���dS(N(R	(t	argumentsR'(tmessage(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytwrapped_test�s((RPRQ((RPs@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytinvalid�ss/given must be called with at least one argumentsIvarargs or keywords are not supported with positional arguments to @givensFToo many positional arguments for %s() (got %d but expected at most %ds5cannot mix positional and keyword arguments to @givens*%s() got an unexpected keyword argument %risDCannot decorate function %s() because it has destructuring argumentss0Cannot apply @given to a function with defaults.R&tkeywordstvarargstdefaultsc`s��j��jdk	r*t�j�}n'�jrHtt�
��}n	t�}ddlj}d}t	����\���
j
r��j�
j
d�}n�r��d}nt|��	x\t
t�dd(��D]B}|j
r\t|j
�t�j
�kr0tdt�j
�t|j
�f��ntt�j
t|j
�|j
���n	|j�tj�jkr}q�n�j��d�
jt�
���f}y2t��#}�	d���
fd��WdQXWq�tk
rt|�x|jD]}t|�q�W�q�Xq�W�jdkr1dSt���|j |j!��|j"��j#�fd���}	�fd��|	�|dk	r�t$�|��n�j%��j&}
|
t'j(j&M}
ddl)m*}m+}m,�tj-�jkptj.�jks
dS|
rt|j/d	���|d
�j0d�fd��}
t'�d
t1j2��6y�	|
t3�d���Wntk
r�nXWdQXd}d}d}t4j4�}x�|dkrAt4j4�|dkrA|dkrA|dkrAyd|d
�j0d�fd��}
t'�d
t1j2���	|
t3�d���WdQX|d7}Wq�t5k
rr|d7}q��k
r�|
j6|j7kr�|d7}q>|
j6|j8ks�t9�|d7}q�tk
r��q�t:k
r=t;j<�j=kr��ntt>j?���	t@kr*�dt;j<�q>�dt;j<�q�Xq�W|dksa|r~|dkr~�d||ft;jA�n|dks�|r�|dkr��d||ft;jB�nt4j4�|}|dks�|dkr�d||||ft;jC�qndg�dg}������
�	fd�}ddlDmE}d}tFtG�
��}t4j4�}||d�d|d|�}|jH�t4j4�|}�jIdko�|�jIk}|jJdkr�dS|jJj6|jKkr!|jJjL}�jMdk	r��jMjN||�q�ns|jOtP�jQ�j�kr�|rntRd d!tS�
�|jO|f��q�tTd"tS�
�|jOf��ndS�ddk	s�t9�y<��0�	|jU|�t3��
d#tVd$tV��WdQXWn3t5�fk
rtt>j?��tWd%��nXtd&�d�d'}y<�	|jU|�t3�tX�
|d�d#tVd$tV��Wn#t5�fk
r�tW|��nXdS()NiR0sGexample has too many arguments for test. Expected at most %d but got %dsFalsifying example: %s(%s)c`s
����S(N((R>(ROtexample_kwargsR)(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9tc`s
t|��S(N(tdict(R&(R'(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9 RWc`s>|�jkrdS|d7}|d|f7}t|��dS(Nsd
See http://hypothesis.readthedocs.org/en/latest/healthchecks.html for more information about this. sjIf you want to disable just this health check, add %s to the suppress_health_check settings for this test.(tsuppress_health_checkR
(RPtlabel(R(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytfail_health_check$s(tTestDatatStatustStopTesti�t
max_lengtht
draw_bytesc`s
|�|�S(N((R>tntdistribution(thealth_check_random(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9Jst	verbosityc_`sdS(N(RF(R&R'((s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9QRWi
ii2ic`s
|�|�S(N((R>RaRb(Rc(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9`sc_`sdS(N(RF(R&R'((s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9fRWs�An exception occurred during data generation in initial health check. This indicates a bug in the strategy. This could either be a Hypothesis bug or an error in a function you've passed to it to construct your data.s`An exception occurred during data generation in initial health check. This indicates a bug in the strategy. This could either be a Hypothesis bug or an error in a function you've passed to it to construct your data. Additionally, you have a custom executor, which means that this could be your executor failing to handle a function which returns None. s+Examples routinely exceeded the max allowable size. (%d examples overran while generating %d valid ones). Generating examples this large will usually lead to bad results. You should try setting average_size or max_size parameters on your collections and turning max_leaves down on recursive() calls.s[It looks like your strategy is filtering out a lot of data. Health check found %d filtered examples but only %d good ones. This will make your tests much slower, and also will probably distort the data generation quite a lot. You should adapt your strategy to filter less. This can also be caused by a low max_leaves parameter in recursive() callsg�?s�Data generation is extremely slow: Only produced %d valid examples in %.2f seconds (%d invalid ones and %d exceeded maximum size). Try decreasing size of the data you're generating (with e.g.average_size or max_leaves parameters).c`s�yU�|t����}|dk	rP�jrP�d�j|ftj�ntSWnotk
rr|j�nUt	t
�fk
r��n9tk
r�tj
��d<t�d�|j�nXdS(NsFTests run under @given should return None, but %s returned %r instead.i(RCRFtperform_health_checkR%Rtreturn_valuetFalseRtmark_invalidRR
t	Exceptiont	tracebackt
format_excRtmark_interesting(R>tresult(R^R[tlast_exceptionR@RR)ttest_runner(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytevaluate_test_data�s$	


(t
TestRunnerRR"tdatabase_keysVRan out of time before finding a satisfying example for %s. Only found %d examples in s%.2fs.saUnable to satisfy assumptions of hypothesis %s. Only %d examples considered satisfied assumptionsR?R8s\Unreliable assumption: An example which satisfied assumptions on the first run now fails it.s*Failed to reproduce exception. Expected: 
sUnreliable test data: Failed to reproduce a failure and then when it came to recreating the example in order to print the test data with a flaky result the example was filtered out (by e.g. a call to filter in your strategy) when we didn't expect it to be.((Yt!_hypothesis_internal_use_settingsRDRFRtderandomizeRR$RBt
strategiesRR&tgetRtreversedtgetattrtlenR	RXtzipR'RtexplicittphasestupdateR%RR
t
BaseExceptionRtnotestmax_examplesR3ttuplestjusttfixed_dictionariestmapREtvalidateRetSettingstdefaultt#hypothesis.internal.conjecture.dataR\R]R^treusetgenerateR#tbuffer_sizeRtquietRCttimeRtstatustINVALIDtOVERRUNRGRiRtexception_in_generationRYRjRkRtdata_too_largetfilter_too_muchttoo_slowt%hypothesis.internal.conjecture.engineRqRRRAttimeoutt	last_datatINTERESTINGtbuffertdatabasetsavetvalid_examplestmintmin_satisfying_examplesRR Rt
for_buffertTrueRR.(ROR'R"tsdtselfyR5tmessage_on_failuretbRatgiven_specifierReR\R]R>tcounttoverrunstfiltered_drawststarttruntimetrepr_for_last_exceptionRpRqtfalsifying_exampleRrt
start_timeRItrun_timet	timed_outtfilter_message(targspectgenerator_kwargstoriginal_argspecR)RQ(
R^RORVR[RcR'RnR@RRos@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyRQ�sx				
		%	
 



			

"		







	



		!	
					
t_RDRs(RRTRSRyR&R%t
isinstancetlistRURztinspecttArgSpecRFRRtdirR1tsetattrRxR�tis_hypothesis_testRDR�R�Rs(	R)RRtktextra_kwargsROtatnametstrategytattr(tgenerator_argumentsR�(R�R�R)RQs@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytrun_test_with_generator�sl	



(	
	
!	%				-�P  	((R�R�R�((R�R�s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytgiven�s��c`s��ptdddddd��|dkrK�jdk	rKt��}nt|t�s|td|t|�jf��n|�|p�t	�}dg�dg������fd�}ddl
m}dd	lm
}m}tj�}	||d
�d|d|�}
|
j�tj�|	}|
jj|jkrlt��!|j|
jj�j��SWdQXn|
j�jkr��jdkr�|�jkr�td
t��|
j|f��q�tdt��|
jf��ntt����dS(NR�i�R�itmax_shrinkss-Expected SearchStrategy but got %r of type %sc	`st��Xy5t|_|j���|j�����}Wntk
r\|j�nXWdQX|r|�dcd7<n�jtj	kr��ds�t
�fd��q�|r��ddkr�t
�fd��nt
�fd��|�d<q�n|r|jr|j�ndS(Niic`sdt��fS(NuTrying example %s(R((Rm(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9\sc`sdt��fS(NuFound satisfying example %s(R((Rm(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9asc`sdt��fS(NuShrunk example to %s(R((Rm(s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyR9es(
R
R�tis_findR;R7RRhRdRR=RtfrozenRl(R>tsuccess(t	conditionR�tsearchRtsuccessful_examples(Rms@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyttemplate_conditionMs(
	


(Rq(R\R]RR"RrsjRan out of time before finding enough valid examples for %s. Only %d valid examples found in %.2f seconds.sVUnable to satisfy assumptions of %s. Only %d examples considered satisfied assumptions(R�RFR�RR�R!R	ttypeR%R$R�RqR�R\R]R�RAR�R�R�R
R�R�R;R�R�R�RR RR(t	specifierR�RR"RrR�RqR\R]R�RIR�((R�R�R�RR�s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pytfind7sJ				

%		(>t__doc__t
__future__RRRR�R�R+RjR"RtcollectionsRthypothesis.errorsRRRRR	R
RRR:R
thypothesis._settingsRR�RRRthypothesis.executorsRRthypothesis.reportingRRRthypothesis.internal.compatRRthypothesis.internal.reflectionRRRRRRRR t$hypothesis.searchstrategy.strategiesR!R$R.R/R5RgRCR<RER�RFR�(((s@/opt/alt/python27/lib/python2.7/site-packages/hypothesis/core.pyt<module>s6::					��