U aNW@srdZddlmZddlZddladdlZddlZdZtdZ ej dkZ e r\ddl Z ej Z n ddlZ ddlZGdddeZ dadadadadadadadZdadadadadaeaea da!d d Z"d d Z#d dZ$ddZ%ddZ&ddZ'ddZ(ddZ)ddZ*ddZ+ddZ,dd Z-d!d"Z.gZ/gZ0d#d$Z1d%d&Z2e1d'd(Z3e1d)d*Z4e1d+d,Z5e1d-d.Z6e2d/d0Z7e2d1d2Z8e2d3d4Z9e2d5d6Z:d7d8Z;e2d9d:ZZ>e2d?d@Z?dAdBZ@dCdDZAdEdFZBdGdHZCdIdJZDdKdLZEdMdNZFdOdPZGdQdRZHdSdTZIdUdVZJdWdXZKdcdYdZZLd[d\ZMd]d^ZNGd_d`d`e ZOdaPdadbZQdS)dzTesting extensions. this module is designed to work as a testing-framework-agnostic library, created so that multiple test frameworks can be supported at once (mostly so that we can migrate to new ones). The current target is pytest. )absolute_importNFzsqlalchemy.testing.plugin_base)rc@seZdZejZdS)ABCN)__name__ __module__ __qualname__abcABCMeta __metaclass__r r fC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\testing\plugin\plugin_base.pyr)srcCs|ddttdd|ddttdd|ddtd d d |d dtd d|ddtddd |dddddd |ddddd|dddd|dddd d|d!dd"d#d|d$dd%d&d|d'td(d)d*d+|d,td-d.d/|d0td1d2|d3dd4d5d|d6td7d8d/|d9dd:d;ddttd?d|d@ddAd;dBd=|dCdttdDdE|dFdttdGdE|dHddId;dJd=|dKddLd;dMd=|dNtdOdPd/|dQtdgdRdSdTdS)UNz --log-infocallbackz,turn on info logging for (multiple OK))actiontyper helpz --log-debugz-turn on debug logging for (multiple OK)z--dbappenddbzBUse prefab database uri. Multiple OK, first one is run by default.)rrdestrz--dbszList available prefab dbs)rZzeroarg_callbackrz--dburidburiz8Database uri. Multiple OK, first one is run by default.z --dbdriverstringdbdriverz|Additional database drivers to include in tests. These are linked to the existing database URLs by the provisioning system.z --dropfirst store_true dropfirstz,Drop all tables in the target database first)rrrz--disable-asyncioz8disable test / fixtures / provisoning running in asyncio)rrz--backend-only backend_onlyzUse a low number of distinct connections - i.e. for Oracle TNSz--write-idents write_identszCwrite out generated follower idents to , when -n is usedz --reversetop reversetopFzTUse a random-ordering set implementation in the ORM (helps reveal dependency issues))rrrrz--requirementsz3requirements class for testing, overrides setup.cfgz--with-cdecimalcdecimalzDMonkeypatch the cdecimal library into Python 'decimal' for all testsz --include-tagzInclude tests with tag )rr rrz --exclude-tagzExclude tests with tag z--write-profilesZwrite_profilesz$Write/update failing profiling data.z--force-write-profilesZforce_write_profilesz,Unconditionally write/update profiling data.z--dump-pyannotateZdump_pyannotatez/Run pyannotate and dump json info to given filez--mypy-extra-test-pathZmypy_extra_test_pathszlAdditional test directories to add to the mypy tests. This is used only when running mypy tests. Multiple OK)rrrrr)str_log _list_dbs_requirements_opt _include_tag _exclude_tag) make_optionr r r setup_optionsAsF r*cCsddlm}||_dS)zConfigure required state for a follower. This invokes in the parent process and typically includes database creation. r provisionN)sqlalchemy.testingr,FOLLOWER_IDENT)Zfollower_identr,r r r configure_followers r/cCsttd|d<dS)aSStore 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 pytest 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.  include_tags exclude_tagsmemoized_configNr0Zdict_r r r !memoize_important_follower_configs r5cCs(t|ddt|dddS)zfRestore important configuration needed by a follower. This invokes in the follower process. r3r1r2N)r1updater2r4r r r !restore_important_follower_config sr7cCstatddgdS)Nz setup.cfgztest.cfg) configparser ConfigParser file_configreadr r r r read_configsr<cCs|atD]}|ttqdS)z7things to set up early, before coverage might be setup.N)options pre_configurer:)optfnr r r pre_beginsrAcCs |t_dSN)r=Z has_coverage)valuer r r set_coverage_flag%srDcCsptD]}|ttqddlmaddlmamamaddlm a m a m a ddlm a m a ddlmat dS)z9things to set up later, once we know coverage is running.rtesting)fixturesengines exclusions) assertionswarnings profiling)configr,)utilN)post_configurer=r: sqlalchemyrFr-rGrHrIrJrKrLrMr,rNZ setup_filtersr@r r r post_begin)s   rRcCsRtsddlat|dr2t|tjn|drNt|tjdS)Nrz-infoz-debug)logging basicConfigendswith getLoggersetLevelINFODEBUGopt_strrCparserr r r r$;s  r$cGsBtdttdD]}td|td|fqtddS)Nz0Available --db options (use --dburi to override)rz%20s %sr)printsortedr:r=getsysexit)argsmacror r r r%Hsr%cCs t|dSrB)_setup_requirementsrZr r r r&Osr&cCst|dddSN-_)r2addreplacerZr r r r(Ssr(cCst|dddSre)r1rhrirZr r r r'Wsr'cCst||SrB)r>rrQr r r pre_s rjcCst||SrB)rOrrQr r r postds rkcCs|adSrBr=r?r:r r r _setup_optionsisrncCs|jrtddS)NZmemory_intensive)rr2rhrmr r r _set_nomemoryosrocCs|jrtddS)NZtiming_intensive)rr2rhrmr r r _set_notimingintensiveusrpcCs|jrddl}|tjd<dS)Nrdecimal)r"r`modules)r=r:r"r r r _monkeypatch_cdecimal{srscCsddlm}t|_dSNrrM)r-rM_fixture_fn_classZ_fixture_functions)r=r:rMr r r _init_symbolss rwcCs |js tsddlm}d|_dS)Nr)asyncioF)Zdisable_asynciopy3kr-rxZENABLE_ASYNCIO)r?r:rxr r r _set_disable_asyncios  rzc Cs@ddlm}ddlm}ddlm}|jr6t|j}ng}|jpBg}|jr|jD]D}t d|D]2}|| dkrt d|q`| |d|q`qP|s| |ddd|_t|||} | D]t} td | |jr|jrt|jd } | |jd | d W5QRX|| |||j} |js| | |qdS) NrrErur+z[,\s]+rz:Unknown URI specifier '%s'. Specify --dbs for known uris.rzAdding database URL: %sa  )rPrFr-rMr,rlistrrresplitr= RuntimeErrorrr__currentZgenerate_db_urlsloginfor r.openwriteZ setup_configZset_as_current) r=r:rFrMr,Zdb_urlsZ extra_driversZdb_tokenrZ expanded_urlsZdb_urlfile_cfgr r r _engine_urisD       "rcCs|dd}t|dS)N sqla_testingrequirement_cls)r_rd)r=r:rr r r _requirementss rcCsddlm}ddlm}|jdk r&dS|d\}}t|}|dddD]}t||}qNt||}||_|_t |_ dS)NrrurE:.) r-rMrPrF requirementsr __import__getattrrequiresbootstrapped_as_sqlalchemy)ZargumentrMrFmodnameZclsnamemod componentZreq_clsr r r rds     rdcCs@ddlm}|jrsz+_possible_configs_for_cls..)key)setrMrrZ__unsupported_on__rIdb_specr~removerrNto_listrintersection_updaterrrrZmatching_config_reasonsextendrZenabled_for_configrh differencedifference_updatereversedr^rrvalues)rreasonsrrspec config_objr requirementcheckZ skip_reasons non_preferredZ per_dialectrrr r r rs^                        rcCsg}t||}t|ddrFt|dD] }|r$td|j|jfq$|sd|jdddtjDd|f}t|nRt|drt }t j t |j}|D]}||s||q||r||tj|krt||dS) NZ __skip_if__Fz'%s' skipped by %sz.'%s' unsupported on any DB implementation %s%sz, c ss<|]4}d|jjdddt|jD|jjfVqdS)z '%s(%s)+%s'rcss|]}t|VqdSrB)r#).0digr r r sz&_do_skips...N)rrjoinrIZ_server_versionr)rrr r r rs   z_do_skips..__prefer_backends__)rrrMZ skip_testrrrrrrrIrrNrrrhrrr _setup_configpop)rrrcmsgrrrr r r rs6          rcCstj|tdSrB)rMrpushrF)rctxr r r rsrc@sZeZdZejddZejddZejddZejddZd d Z ejd d Z d S)FixtureFunctionscOs tdSrBNotImplementedErrorselfargkwr r r skip_test_exceptionsz$FixtureFunctions.skip_test_exceptioncOs tdSrBrrrbrr r r combinationsszFixtureFunctions.combinationscOs tdSrBrrr r r param_identszFixtureFunctions.param_identcOs tdSrBrrr r r fixtureszFixtureFunctions.fixturecCs tdSrBrrr r r get_current_test_namesz&FixtureFunctions.get_current_test_namecCs tdSrBrrr r r mark_base_test_class sz%FixtureFunctions.mark_base_test_classN) rrrrabstractmethodrrrrrrr r r r rs    rcCs|adSrB)rv)Zfixture_fn_classr r r set_fixture_functionssr)NF)R__doc__ __future__rrrSrr`rrVr version_inforyr8rr9 collectionscollections_abcobjectrGrHrIrKrLr,rJrrMrFrNr:rr1r2r=r*r/r5r7r<rArDrRr$r%r&r(r'r>rOrjrkrnrorprsrwrzrrrdrrrrrrrrrrrrrrrrrrrrrvrr r r r s   0          -         B*