• File: plugin_base.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyc
  • Date Modified: 08/01/2016 8:07 PM
  • File size: 18.77 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

M!Vc@@sdZddlmZyddlmZWn!ek
rMddlmZnXddlZddl	Z	ej
d,kZerddlZnddl
ZdadadZdadadadZdadadadaiaeaeadadZdZ d	Z!d
Z"dZ#dZ$d
Z%dZ&dZ'dZ(dZ)dZ*dZ+gZ,gZ-dZ.dZ/e.dZ0e.dZ1e.dZ2e/dZ3e/dZ4e/dZ5dZ6e/dZ7e/dZ8e/dZ9d Z:d!Z;d"Z<d#Z=d$Z>d%Z?d&Z@d'ZAd(ZBdd)ZCd*ZDd+ZEdS(-sGTesting extensions.

this module is designed to work as a testing-framework-agnostic library,
so that we can continue to support nose and also begin adding new
functionality via py.test.

NOTE:  copied/adapted from SQLAlchemy master for backwards compatibility;
this should be removable when Alembic targets SQLAlchemy 1.0.0


i(tabsolute_import(tSkipTest(tSkippedNic
C@s|ddddddtdd|ddddddtdd	|d
dddddd
dd|ddddtdd|ddddddddd|ddddddd|ddddddd|ddddddd|ddddddd |d!dddd"d#tdd$|d%dddddtdd&|d'dddd(d#tdd)|d*dddtdddd+|d,dddtdddd-|d.dddd/|d0dd1dd2d#ddd3dS(4Ns
--log-infotactiontcallbackttypetstringthelps,turn on info logging for <LOG> (multiple OK)s--log-debugs-turn on debug logging for <LOG> (multiple OK)s--dbtappendtdesttdbsBUse prefab database uri. Multiple OK, first one is run by default.s--dbssList available prefab dbss--dburitdburis8Database uri.  Multiple OK, first one is run by default.s--dropfirstt
store_truet	dropfirsts,Drop all tables in the target database firsts--backend-onlytbackend_onlys&Run only tests marked with __backend__s
--mockpooltmockpools0Use mock pool (asserts only one connection used)s--low-connectionstlow_connectionss>Use a low number of distinct connections - i.e. for Oracle TNSs--reversetopt
reversetoptdefaultsTUse a random-ordering set implementation in the ORM (helps reveal dependency issues)s--requirementss3requirements class for testing, overrides setup.cfgs--with-cdecimaltcdecimalsDMonkeypatch the cdecimal library into Python 'decimal' for all testss
--include-tagsInclude tests with tag <tag>s
--exclude-tagsExclude tests with tag <tag>s--serversides"Turn on server side cursors for PGs--mysql-enginetstoretmysql_engines\Use the specified MySQL storage engine for all tables, default is a db-default/InnoDB combo.(t_logt	_list_dbstFalset_requirements_optt_include_tagt_exclude_tagtNone(tmake_option((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt
setup_options9sPcC@sddlm}||_dS(sConfigure required state for a follower.

    This invokes in the parent process and typically includes
    database creation.

    i(t	provisionN(talembic.testingRtFOLLOWER_IDENT(tfollower_identR((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytconfigure_followerjscC@s#itd6td6td6|d<dS(sTStore important configuration we will need to send to a follower.

    This invokes in the parent process after normal config is set up.

    This is necessary as py.test seems to not be using forking, so we
    start with nothing in memory, *but* it isn't running our argparse
    callables, so we have to just copy all of that over.

    tdb_optstinclude_tagstexclude_tagstmemoized_configN(R$R%R&(tdict_((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt!memoize_important_follower_configus
cC@sCtj|ddtj|ddtj|dddS(sfRestore important configuration needed by a follower.

    This invokes in the follower process.

    R'R$R%R&N(R$tupdateR%R&(R(((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt!restore_important_follower_configscC@s#tjatjddgdS(Ns	setup.cfgstest.cfg(tconfigparsertConfigParsertfile_configtread(((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytread_configscC@s(|axtD]}|ttq
WdS(s7things to set up early, before coverage might be setup.N(toptionst
pre_configureR.(topttfn((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt	pre_begins
cC@s
|t_dS(N(R1thas_coverage(tvalue((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytset_coverage_flagscC@snxtD]}|ttqWddlmamamaddlmamaddl	m
a
tjdS(s9things to set up later, once we know coverage is running.i(tconfigtwarningst
exclusions(tenginestfixtures(tutilN(tpost_configureR1R.R R9R:R;R<R=t
sqlalchemyR>t
setup_filters(R4((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt
post_begins
cC@sytsddlatjn|jdrJtj|jtjn+|jdrutj|jtjndS(Nis-infos-debug(tloggingtbasicConfigtendswitht	getLoggertsetLeveltINFOtDEBUG(topt_strR7tparser((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRs
cG@sQdGHx8ttjdD]!}d|tjd|fGHqWtjddS(Ns0Available --db options (use --dburi to override)R
s%20s	%si(tsortedR.R1tgettsystexit(targstmacro((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRscC@st|dS(N(t_setup_requirements(RJR7RK((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRscC@stj|jdddS(Nt-t_(R&taddtreplace(RJR7RK((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRscC@stj|jdddS(NRSRT(R%RURV(RJR7RK((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRscC@stj||S(N(R2R(R4((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytpres
cC@stj||S(N(R?R(R4((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytposts
cC@s
|adS(N(R1(R3R.((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt_setup_optionsscC@s|jrttd<ndS(Ntserver_side_cursors(t
serversidetTrueR$(R1R.((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt_server_side_cursorss	cC@s)|jr%ddl}|tjd<ndS(Nitdecimal(RRNtmodules(R1R.R((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt_monkeypatch_cdecimals	c	C@s-ddlm}ddlm}|jr;t|j}ng}|jrxr|jD]d}x[tjd|D]G}||jdkrt	d|qm|j
|jd|qmWqTWn|s|j
|jddnxE|D]=}|j|t
|||j}|js|j|qqWdS(Ni(R9(Rs[,\s]+R
s:Unknown URI specifier '%s'.  Specify --dbs for known uris.R(R R9RRtlistR
tretsplitR1tRuntimeErrorRRMtsetup_configR$R!t_currenttset_as_current(	R1R.R9Rtdb_urlstdb_tokenR
tdb_urltcfg((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt_engine_uris(		
$
	cC@s-|jr)ddlm}|jtd<ndS(Ni(tpoolt	poolclass(RR@Rmt
AssertionPoolR$(R1R.Rm((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt_engine_pools	cC@s |jdd}t|dS(Ntsqla_testingtrequirement_cls(RMRR(R1R.Rr((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt
_requirementsscC@sddlm}|jdk	r#dS|jd\}}t|}x*|jddD]}t||}qXWt||}||_dS(Ni(R9t:t.i(R R9trequirementsRRct
__import__tgetattr(targumentR9tmodnametclsnametmodt	componenttreq_cls((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRR#scC@sddlm}ddlm}ddlm}ddlm}|jr\ddlm	}nddl
m}|j}|j
rx<|jjD](}|j}	||	}
y|
j}Wntk
rn:Xx6|D].}|	j|j|j||jqW|jjj|ry|
jdd	}Wntk
rDqXx?|D]4}|	j|j|j||jdd	qLWnxHt|
jd
dD].}
|	j|j|j|
|jqW|jjj|rAxWt|
jd
ddd	D]4}
|	j|j|j|
|jdd	qWn||dr|jrdd
lm}xJ|
j dD]6}|	j|j!|j"d|dd|dqyWqqWndS(Ni(R9(tagainst(tschema(R>(tinspect(t	InspectorRttest_schematorder_bytforeign_keyt
postgresql(Rt*tname(#R R9talembic.testing.exclusionsRR@RtalembicR>tsqla_08Rtsqlalchemy.engine.reflectionRtfrom_engineR
tConfigtall_configsR
tget_view_namestNotImplementedErrortexecutet	_DropViewtTabletMetaDataRvtschemastenabled_for_configtreversedtget_table_namest	DropTabletsqla_100tsqlalchemy.dialectsRt	get_enumstDropEnumTypetENUM(R1R.R9RRR>RRRktet	inspectort
view_namestvnamettnameRtenum((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt_prep_testing_database5s\				

 	


 	
cC@s'|jr#ddlm}|ndS(Ni(trandomize_unitofwork(Rtsqlalchemy.orm.utilR(R1R.R((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt_reverse_topologicalts	cC@s&ddlm}t|_||_dS(Ni(R9(R R9R1R.(R3R.R9((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt_post_setup_options{s	cC@sWt|tjstS|jjdr,tStjjrOt	|dtrOtSt
SdS(NRTt__backend__(t
issubclassR=tTestBaseRt__name__t
startswithR9R1RRxR\(tcls((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt
want_classs
cC@s|jjdstS|jdkr)tStr~t|dr\tj|j	j
ttp}t|do}|jj
ttStrt|drtj|j	j
ttStrt|dr|jj
ttSt
SdS(Nttest_t__tags__t_sa_exclusion_extend(RRRt
__module__RR%thasattrR;ttagsRtinclude_testR&RR\(RR4((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytwant_methods"	

cc@st|dtrxt|D]o}d|j|jj|jjf}t||fid|jj|jjfd6}t||||VqWn|VdS(NRs%s_%s_%ss%s+%st__only_on__(	RxRt_possible_configs_for_clsRR
RtdriverRtsetattr(RtmoduleRkRtsubcls((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytgenerate_sub_testss"#cC@st|t|dS(N(t	_do_skipst
_setup_engine(R((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytstart_test_classs
cC@stdS(N(t_restore_engine(R((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytstop_test_classscC@stjjdS(N(R9Rftreset(((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRscC@s>t|ddr:tjd|j}tjj|ndS(Nt__engine_options__R1(RxRR<ttesting_engineRR9Rftpush_engine(Rteng((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRscC@sdS(N((ttestttest_module_namet
test_classt	test_name((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pytbefore_testscC@sdS(N((R((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt
after_testsc
C@sttjj}|jrftj|j}x3t|D]"}||r=|j|q=q=Wnt	|ddrtjtj|j
}x3t|D]"}||s|j|qqWnt|dr`tj}x|t|D]k}xb|jD]W}t	||}|j|}|r|j||dk	rQ|j|nPqqWqWnt|drt}	tj}xVt|D]H}x?|jD]4}t	||}|j|s|	j|qqWqW|j|	r|j|	qn|S(NRt__requires__t__prefer_requires__(tsetR9RRt__unsupported_on__R;tdb_specRatremoveRxRR>tto_listRRRvRtmatching_config_reasonstextendRRRUt
differencetdifference_update(
RtreasonsRtspect
config_objRvtrequirementtchecktskip_reasonst
non_preferred((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRsB		
		cC@sg}t||}t|dtrlxBt|dD].}|r7td|j|jfq7q7Wn|st|dtrd|j|jf}n;d|jdjdtjj	Ddj|f}t|nt
|drit}tj
tj|j}x*|D]"}||s!|j|q!q!W|j|ri|j|qintj|krt|j|ndS(	Nt__skip_if__s'%s' skipped by %sRs('%s' unsupported for implementation '%s's.'%s' unsupported on any DB implementation %s%ss, cs@sJ|]@}d|jjdjd|jjjD|jjfVqdS(s'%s(%s)+%s'Rucs@s|]}t|VqdS(N(tstr(t.0tdig((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pys	<genexpr>sN(R
Rtjointdialecttserver_version_infoR(RR((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pys	<genexpr>st__prefer_backends__(RRxRRRRRR9RRRRR;RR>RRRURRRft
_setup_configtpop(RRRtctmsgRRR((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyRs8	 	
cC@stjj|dS(N(R9Rftpush(Rtctx((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyR+s(ii(Ft__doc__t
__future__RtnoseRtImportErrort_pytest.runnerRRNRbtversion_infotpy3kR,R-RR=R<RR;R:t
assertionsRvR9R>R.RCR$RR%R&R1RR#R)R+R0R5R8RBRRRRRR2R?RWRXRYR]R`RlRpRsRRRRRRRRRRRRRRRRR(((sS/opt/alt/python27/lib/python2.7/site-packages/alembic/testing/plugin/plugin_base.pyt<module>s
			1														 	?									+	,