Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

hemamaps / django-crispy-forms   python

Repository URL to install this package:

Version: 1.6.0 

/ tests / test_form_helper.pyc

ó
X2ÔUc@sÞddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
mZddlZyddl
mZWn-ek
r½ddl	mZeƒjZnXdd	lmZd
dlmZmZmZd
dlmZdd
lmZmZmZmZmZddl m!Z!ddl"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.ddl/m0Z0d„Z1d„Z2d„Z3d„Z4d„Z5d„Z6d„Z7d„Z8d„Z9d„Z:d„Z;d„Z<d„Z=d „Z>d!„Z?d"„Z@d#„ZAd$„ZBd%„ZCd&„ZDd'„ZEd(„ZFed)„ƒZGed*„ƒZHed+„ƒZIed,„ƒZJed-„ƒZKed.„ƒZLed/„ƒZMed0„ƒZNdS(1iÿÿÿÿN(tforms(treverse(tformset_factory(t_get_new_csrf_key(tTemplateSyntaxErrortContext(tget_template_from_string(tEngine(t
ugettext_lazyi(t
only_uni_formtonly_bootstrap3tonly_bootstrap(tTestForm(tFieldWithButtonstPrependedAppendedTexttAppendedTextt
PrependedTexttStrictButton(t	text_type(t
FormHelpertFormHelpersException(tLayouttSubmittResettHiddentButtont
MultiFieldtField(trender_crispy_form(tCrispyFormNodecCsŸtƒ}|jtddddƒƒ|jtddƒƒ|jtddƒƒ|jtd	d
ƒƒtdƒ}titƒd6|d
6ƒ}|j	|ƒ}d|ks±t
‚d|ksÃt
‚d|ksÕt
‚d|ksçt
‚d|ksùt
‚|jdkrAd|kst
‚d|ks,t
‚d|ks›t
‚nZd|ksSt
‚d|kset
‚d|kswt
‚tt
jd|ƒƒdks›t
‚dS(Ns	my-submitRt	css_classsbutton whitesmy-resetRs	my-hiddenRs	my-buttonRuP
        {% load crispy_forms_tags %}
        {% crispy form form_helper %}
    tformtform_helpersid="submit-id-my-submit"sid="reset-id-my-reset"sname="my-hidden"sid="button-id-my-button"tuni_formssubmit submitButtonsreset resetButtonsclass="button"sclass="btn"sbtn btn-primarysbtn btn-inverses<input[^>]+> <i(Rt	add_inputRRRRRRRtrendertAssertionErrortCRISPY_TEMPLATE_PACKtlentretfindall(tsettingsR ttemplatetcthtml((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_inputs's,		cCs;tƒ}yd|_tjdƒWntk
r6nXdS(Nt	superPostsJSetting an invalid form_method within the helper should raise an Exception(Rtform_methodtpytesttfailR(R ((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_invalid_form_methodFs		
cCs¨tƒ}d|_d|_d|_d|_d|_tdƒ}tidd6d	d
6ƒ}|jƒt	i|d6|d6ƒ}|j
|ƒ}|jd
ƒdksªt‚d|ks¼t‚d|ksÎt‚d|ksàt‚dt
dƒ|ksüt‚|jdkr d|ks t‚nd|ks2t‚d|ksDt‚t|_|j
|ƒ}d
|ksnt‚d|ks€t‚d|ks’t‚d|ks¤t‚dS(Nsthis-form-rockssforms-that-rocktGETtsimpleActiontERRORSuT
        {% load crispy_forms_tags %}
        {% crispy testForm form_helper %}
    twargamet	password1tgodt	password2ttestFormR s<formismethod="get"sid="this-form-rocks"saction="%s"R!sclass="uniForms<li>Passwords dont match</li>(Rtform_idt
form_classR/tform_actiontform_error_titleRRtis_validRR#tcountR$RR%tFalsetform_tag(R)R R*RR+R,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt$test_form_with_helper_without_layoutOs6							
	cCs tidd6dd6ƒ}tƒ|_t|j_|jƒtdƒ}ti|d6ƒ}|j|ƒ}d|ks|t	‚t
tdƒƒ|ksšt	‚d	|ks¬t	‚t|j_ti|d6ƒ}|j|ƒ}d|ksìt	‚t
tdƒƒ|ks
t	‚d	|kst	‚dS(
NR6R7R8R9uH
        {% load crispy_forms_tags %}
        {% crispy testForm %}
    R:s<li>Passwords dont match</li>sThis field is required.terror(
RRthelpertTruetform_show_errorsR?RRR#R$Rt_RA(RR*R+R,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt&test_form_show_errors_non_field_errorsys"
	cCsytƒ}tƒ|_t|j_t|ƒ}|jdƒdksHt‚tƒ}tƒ|_t|j_t|ƒ}dS(Nsrequired="required"i(	RRRERFthtml5_requiredRR@R$RA(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_html5_required˜s		cCsctƒ}tƒ|_idd6dd6|j_t|ƒ}d|ksMt‚d|ks_t‚dS(Nt
TestIdFormtidtofftautocompletesautocomplete="off"sid="TestIdForm"(RRREtattrsRR$(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt
test_attrs¦s	cCstƒ}idd6dd6dd6dd6|_td	d
ƒ}|j|itƒ}|ddksht‚|dddks‚t‚d|d
ks˜t‚d|ddks²t‚|ddksÈt‚|dddksât‚|dddksüt‚dS(Ns	test-formRMs
test-formstclassssubmit/test/formtactionRNRORRER;t
form_attrsR<R=(RRPRtget_response_dictRAR$(REtnodetcontext((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_template_context°s	
cCsÜtƒ}d|_d|_d|_tddƒ}|j|itƒ}|ddks^t‚|dddksxt‚d|d	ksŽt‚d|dd
ks¨t‚|ddks¾t‚|dddksØt‚dS(
Ns	test-forms
test-formsssubmit/test/formRRER;RTRMR<RRR=RS(RR;R<R=RRURAR$(RERVRW((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt&test_template_context_using_form_attrsÄs				cCs,tƒ}d|_|ddks(t‚dS(Ns	test-formR;(RR;R$(RE((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_template_helper_accessÔs		cCstdƒ}titƒd6ƒ}|j|ƒ}d|ksCt‚d|ksUt‚d|ksgt‚|jdkr‹d|ks‹t‚ndS(NuD
        {% load crispy_forms_tags %}
        {% crispy form %}
    Rs<forms
method="post"RSR!tuniForm(RRRR#R$R%(R)R*R+R,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_without_helperÛs	cCs|j}|dkrdpd}td|ƒ}titƒd6ƒ}|j|ƒ}|dkrwd|ks‰t‚nd|ks‰t‚dS(NR!t	bootstrapuM
        {%% load crispy_forms_tags %%}
        {%% crispy form "%s" %%}
    Rs
control-groupR[(R%RRRR#R$(R)tcurrent_packt
override_packR*R+R,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt#test_template_pack_override_compactës	
cCs—|j}|dkrdpd}td|ƒ}titƒd6tƒd6ƒ}|j|ƒ}|dkrd|ks“t‚nd|ks“t‚dS(NR!R]uY
        {%% load crispy_forms_tags %%}
        {%% crispy form form_helper "%s" %%}
    RR s
control-groupR[(R%RRRRR#R$(R)R^R_R*R+R,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt#test_template_pack_override_verboseýs	
 cCs&ytdƒWntk
r!nXdS(NuV
            {% load crispy_forms_tags %}
            {% crispy form 'foo' %}
        (RR(((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt!test_template_pack_override_wrongs

cCstdƒ}titƒd6dd6ƒ}t|_|jrptjdkrptj	t
ƒ|j|ƒWdQXn#tj	tƒ|j|ƒWdQX|`dS(NuP
        {% load crispy_forms_tags %}
        {% crispy form form_helper %}
    RtinvalidR ii(ii(
RRRRAtCRISPY_FAIL_SILENTLYtTEMPLATE_DEBUGtdjangotVERSIONR0traisesRR#t	TypeError(R)R*R+((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_invalid_helpers		cCsmtdƒ}tƒ}d|_d|_d|_d|_ttddƒ}|ƒ}ti|d6|d	6t	ƒd
6ƒ}|j
|ƒ}|jdƒdks¢t‚|jd
ƒdks½t‚d|ksÏt‚d|ksát‚d|ksót‚d|kst‚d|kst‚d|ks)t‚dt
dƒ|ksEt‚|jdkrid|ksit‚ndS(NuZ
        {% load crispy_forms_tags %}
        {% crispy testFormSet formset_helper %}
    tthisFormsetRockssformsets-that-rocktPOSTR4textraittestFormSettformset_helpert
csrf_tokens<formis/<input type='hidden' name='csrfmiddlewaretoken'sform-TOTAL_FORMSsform-INITIAL_FORMSsform-MAX_NUM_FORMSs
method="post"sid="thisFormsetRocks"saction="%s"R!sclass="uniForm(RRR;R<R/R=RRRRR#R@R$RR%(R)R*R tTestFormSetRnR+R,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt'test_formset_with_helper_without_layout+s,							$cCsatƒ}tdƒ}titƒd6|d6tƒd6ƒ}|j|ƒ}d|ks]t‚dS(NuP
        {% load crispy_forms_tags %}
        {% crispy form form_helper %}
    RR Rps/<input type='hidden' name='csrfmiddlewaretoken'(RRRRRR#R$(R R*R+R,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_CSRF_token_POST_formMs		'cCsjtƒ}d|_tdƒ}titƒd6|d6tƒd6ƒ}|j|ƒ}d|ksft‚dS(NR3uP
        {% load crispy_forms_tags %}
        {% crispy form form_helper %}
    RR Rps/<input type='hidden' name='csrfmiddlewaretoken'(RR/RRRRR#R$(R R*R+R,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_CSRF_token_GET_form]s			'cCsMtƒ}tƒ}t|_t||itƒd6ƒ}d|ksIt‚dS(NRptcsrf(RRRFtdisable_csrfRRR$(RRER,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_disable_csrfks
			cCsEtƒ}tƒ|_tdƒ|j_t|j_t|ƒ}|jdƒdksZt	‚x$dD]}t
jƒ|j|_
qaWt|ƒ}|jdƒdks¨t	‚|jdƒdksÃt	‚tjdkr|jd
ƒdksít	‚|jdƒdksAt	‚n6|jdƒdks&t	‚|jd
ƒdksAt	‚dS(Ntemails<inputiR7R9ithiddeniistype="hidden" name="password1"stype="hidden" name="password2"sname="password1" type="hidden"sname="password2" type="hidden"(s	password1s	password2(ii(RRRERtlayoutRFtrender_hidden_fieldsRR@R$RtHiddenInputtfieldstwidgetRfRg(t	test_formR,tfield((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_render_hidden_fieldsss"	
cCs^tƒ}tƒ|_tdƒ|j_t|j_t|ƒ}|jdƒdksZt	‚dS(NRxs<inputi(
RRRERRzRFtrender_required_fieldsRR@R$(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_render_required_fieldsŽs	cCsCtƒ}tƒ|_d|j_t|ƒ}d|ks?t‚dS(Nscustom_form_template.htmls<h1>Special custom form</h1>(RRRER*RR$(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_helper_custom_templatešs
	cCsatƒ}tƒ|_tddƒ|j_d|j_t|ƒ}|jdƒdks]t‚dS(NR7R9scustom_field_template.htmls<h1>Special custom field</h1>i(	RRRERRztfield_templateRR@R$(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt!test_helper_custom_field_template£s	cCsëtidd6dd6dd6dd6dd	6ƒ}tƒ|_ttdƒtdƒtdƒtdƒtd	ƒƒ|j_|jƒt|j_t	|ƒ}|j
d
ƒdks´t‚t|j_t	|ƒ}|j
d
ƒdksçt‚dS(
NtinvalidemailRxtfirst_name_too_longt
first_nametlast_name_too_longt	last_nametyesR7R9RDi	i(
RRRERRRzR?RFRGRR@R$RA(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_form_show_errors°s(
				
cCs×tidd6dd6dd6ƒ}tƒ|_ttddƒƒ|j_|jƒt|j_t	|ƒ}|j
dƒdks…t‚ttddƒƒ|j_t|j_t	|ƒ}|j
dƒd	ksÓt‚dS(
NR‡RxRŒR7R9tlegendRDii(
RRRERRRzR?RFRGRR@R$RA(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_multifield_errorsÌs 

cCsýtidd6dd6dd6dd6dd	6ƒ}tƒ|_ttdd
ƒtddƒtddd
ƒtdd
ƒtd	dƒƒ|j_|jƒt	|j_
t|ƒ}|jdƒdksÆt
‚t|j_
t|ƒ}|jdƒdksùt
‚dS(NR‡RxRˆR‰RŠR‹RŒR7R9twhatevertblablatfootbarRDii(RRRERRRRRzR?RFRGRR@R$RA(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_bootstrap_form_show_errorsæs(

cCs:tidd6ƒ}tƒ|_ttddƒtddƒtdddƒƒ}||j_|jƒt	|ƒ}d}|j
dkrd	}ntjd
||tj
ƒ}t|ƒdksÃt‚tidd6ƒ}tƒ|_||j_t|j_t	|ƒ}tjd|tj
ƒ}t|ƒdks6t‚dS(
NR‡RxR‰twatt@R‹shelp-inlinet
bootstrap3s
help-blocks"<span id="error_\d_\w*" class="%s"is'<p id="error_\d_\w*" class="help-block"(RRRERRRRRzR?RR%R'R(t	MULTILINER&R$RAterror_text_inline(R)RRzR,t
help_classtmatches((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_error_text_inlines,
	cCs"tidd6ƒ}tƒ|_t|j_t|j_tdƒ|j_|j	ƒt
|ƒ}|jdƒ}|jdƒ}||kst‚tidd6ƒ}tƒ|_t|j_t|j_tdƒ|j_|j	ƒt
|ƒ}|jdƒ}|jdƒ}||kst‚dS(NR‡Rxs-<span id="hint_id_email" class="help-inline">s,<p id="error_1_id_email" class="help-block">s0<span id="error_1_id_email" class="help-inline">s)<p id="hint_id_email" class="help-block">(
RRRERAR™RFthelp_text_inlineRRzR?RtfindR$(RR,t
help_positionterror_position((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_error_and_help_inline"s(

c	Cs—tƒ}tƒ|_tdtdtdƒƒtddƒtddƒtdd	d
ƒƒ|j_	t
|j_t|ƒ}|j
dƒdks“t‚dS(
NR7R9tConfirmR‰sMr.R‹R–tdatetime_fieldtontsecss<labeli(RRRERR
RRRRRzRAtform_show_labelsRR@R$(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_form_show_labels@s(	cCs¯tƒ}tƒ|_d|j_d|j_t|ƒ}dsEt‚|jdƒdks`t‚d|j_d|j_t|ƒ}dst‚|jdƒdks«t‚dS(Nscol-lg-2scol-lg-8sù<div class="form-group"> <div class="controls col-lg-offset-2 col-lg-8"> <div id="div_id_is_company" class="checkbox"> <label for="id_is_company" class=""> <input class="checkboxinput checkbox" id="id_is_company" name="is_company" type="checkbox" />iscol-sm-3scol-sm-8sù<div class="form-group"> <div class="controls col-sm-offset-3 col-sm-8"> <div id="div_id_is_company" class="checkbox"> <label for="id_is_company" class=""> <input class="checkboxinput checkbox" id="id_is_company" name="is_company" type="checkbox" />(RRREtlabel_classtfield_classRR$R@(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt test_label_class_and_field_class^s	cCsUtƒ}tƒ|_d|j_t|ƒ}d|ks?t‚d|ksQt‚dS(NR!sform-controlt
ctrlHolder(RRREt
template_packRR$(RR,((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyttest_template_packqs	(OR'RfRtdjango.core.urlresolversRtdjango.forms.modelsRtdjango.middleware.csrfRtdjango.templateRRR0tdjango.template.loaderRtImportErrorRtfrom_stringtdjango.utils.translationRRHtconftestR	R
RRtcrispy_forms.bootstrapR
RRRRtcrispy_forms.compatibilityRtcrispy_forms.helperRRtcrispy_forms.layoutRRRRRRRtcrispy_forms.utilsRt+crispy_forms.templatetags.crispy_forms_tagsRR-R2RCRIRKRQRXRYRZR\R`RaRbRjRrRsRtRwRRƒR„R†RRR”RœR¡R§RªR­(((s`/Users/carlton/Documents/Django-Stack/django-crispy-forms/crispy_forms/tests/test_form_helper.pyt<module>sf
(4				*			
							
		"