U eb@sddlZddlZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z mZeeZddgZdd gZd Zed ed d GdddeZGdddeZGdddeZGdddeZGdddeZddZddZddZddZ dS) N) OptionParser)absdirtolist) NoPlugins)warnfilterwarningshelpverbosez ~/.nosercz ~/nose.cfg)win32clialwaysz(.*\.)?nose\.config)categorymodulec@seZdZddZdS)NoSuchOptionErrorcCst||||_dSN) Exception__init__name)selfrr9/opt/hc_python/lib/python3.8/site-packages/nose/config.pyr s zNoSuchOptionError.__init__N)__name__ __module__ __qualname__rrrrrrsrc@s eZdZdS) ConfigErrorN)rrrrrrrr%src@sReZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ dS)ConfiguredDefaultsOptionParserz@ Handler for options from commandline and config files. Ncs@||_||_dkr|jj|_|dkr6fdd}||_dS)Ncs|Srr)msgkwerrorrr4z9ConfiguredDefaultsOptionParser.__init__..)_parser_config_sectionr_error _file_error)rparserZconfig_sectionr file_errorrrrr-s z'ConfiguredDefaultsOptionParser.__init__cCs<g}|j|kr8||jD]\}}||||fq|Sr)r#sectionsitemsappend)rcfgfilenameconfigrvaluerrr _configTuples7s z,ConfiguredDefaultsOptionParser._configTuplesc Cstg}|D]f}t}z||Wn8tjk rZ}ztd|t|fW5d}~XYnX||||q|S)N Error reading config file %r: %s) configparserRawConfigParserreadErrorrstrextendr/)r filenamesr-r,r+excrrr_readFromFilenames>s z1ConfiguredDefaultsOptionParser._readFromFilenamesc Cst}z |j}Wntk r*d}YnXz||Wn8tjk rr}ztd|t|fW5d}~XYnX|||S)Nzr0) r1r2rAttributeErrorreadfpr4rr5r/)rfhr+r,r8rrr_readFromFileObjectJs   z2ConfiguredDefaultsOptionParser._readFromFileObjectcCsVz |jWn8tk rB|}t|tr0|g}n|}||}YnX|}||}|Sr)readliner: isinstancer5r9r=)r config_filesZfilename_or_filenamesr7r-r<rrr_readConfigurationWs   z1ConfiguredDefaultsOptionParser._readConfigurationcCs8d|}||}|dkr$t|n|||||dS)N--) get_optionrprocess)rrr.valuesr&opt_stroptionrrr_processConfigValuefs   z2ConfiguredDefaultsOptionParser._processConfigValuec Cs|D]\}}}|tkrqz|||||Wqtk rh}z|jd||jf||dW5d}~XYqtjk r}z6t|d|t |d}|jd||f||dW5d}~XYqXqdS)Nz/Error reading config file %r: no such option %r)rr,rBr0) option_blacklistrHrr%roptparseOptionValueErrorr5replacerepr) rr&r-rErr.r,r8rrrr_applyConfigurationToValuesns*z:ConfiguredDefaultsOptionParser._applyConfigurationToValuesc Cs|j}z||}Wn0tk rH}z|t|W5d}~XYnHXz||j||Wn0tk r}z|t|W5d}~XYnX|j||Sr)r"get_default_valuesrArr$r5rO parse_args)rargsr@rEr-r8rrrparseArgsAndConfigFiless   z6ConfiguredDefaultsOptionParser.parseArgsAndConfigFiles)NN) rrr__doc__rr/r9r=rArHrOrSrrrrr)s   rc@seZdZdZddZddZddZdd ZeZd d Z d!d dZ ddZ ddZ ddZ d"ddZd#ddZddZddZddZdd Zd S)$ConfigaDnose configuration. Instances of Config are used throughout nose to configure behavior, including plugin lists. Here are the default values for all config keys:: self.env = env = kw.pop('env', {}) self.args = () self.testMatch = re.compile(r'(?:^|[\b_\.%s-])[Tt]est' % os.sep) self.addPaths = not env.get('NOSE_NOPATH', False) self.configSection = 'nosetests' self.debug = env.get('NOSE_DEBUG') self.debugLog = env.get('NOSE_DEBUG_LOG') self.exclude = None self.getTestCaseNamesCompat = False self.includeExe = env.get('NOSE_INCLUDE_EXE', sys.platform in exe_allowed_platforms) self.ignoreFiles = (re.compile(r'^\.'), re.compile(r'^_'), re.compile(r'^setup\.py$') ) self.include = None self.loggingConfig = None self.logStream = sys.stderr self.options = NoOptions() self.parser = None self.plugins = NoPlugins() self.srcDirs = ('lib', 'src') self.runOnInit = True self.stopOnError = env.get('NOSE_STOP', False) self.stream = sys.stderr self.testNames = () self.verbosity = int(env.get('NOSE_VERBOSE', 1)) self.where = () self.py3where = () self.workingDir = None cKs`|di|_}d|_|ddtj|_t|j|_ |dd |_ d|_ |d|_ |d |_ d|_d|_|d tjtk|_d d d g|_tttj|j|_d|_d|_tj|_t|_d|_t|_ d|_!d|_"|dd|_#tj|_$g|_%t&|dd|_'d|_(d|_)t*|_+d|_,d|_-t.|_/d|_0|j12|_3|4||j12|_5dS)NenvrZNOSE_TESTMATCHz(?:^|[\b_\.%s-])[Tt]estZ NOSE_NOPATHFZ nosetestsZ NOSE_DEBUGZNOSE_DEBUG_LOGZNOSE_INCLUDE_EXEz^\.z^_z ^setup\.py$)libsrcTZ NOSE_STOPZ NOSE_VERBOSErI)6poprVrRgetossep testMatchPatrecompile testMatchaddPaths configSectiondebugdebugLogexcludeZgetTestCaseNamesCompatsysplatformexe_allowed_platforms includeExeignoreFilesDefaultStringslistmap ignoreFilesinclude loggingConfigstderr logStream NoOptionsoptionsr&rpluginsZsrcDirsZ runOnInit stopOnErrorstream testNamesint verbositywherepy3wheregetcwd workingDirtraverseNamespacefirstPackageWinsr parserClassworker__dict__copy_defaultupdate_orig)rrrVrrrrsT     zConfig.__init__cCs8|j}|d=|d=|d=|d=|d=|jj|d<|S)NrvrrrVrqrt)rrrt __class__rstaterrr __getstate__s  zConfig.__getstate__cCsV|d}||d|_||_|j|}|j|i|j|j|dS)NrtT) rYrrrt loadPluginsr addOptions configurers)rrZ pluginclsZ dummy_parserrrr __setstate__s   zConfig.__setstate__csL|jid<ddtD}|ddfdd|DS)NrVcSsg|]}|ds|qS)_) startswith.0krrr s z#Config.__repr__..z Config(%s)z, csg|]}d||fqS)z%s=%rrrdrrrs)rrrkkeyssortjoin)rrrrr__repr__s zConfig.__repr__cs6dfdd }tj|d}||dd|S)Ncs<tjdr0j|r0d||f}t|tnt|dS)NexcludedOptionzDOption %r in config file %r ignored: excluded by runtime environment)hasattrrtrrRuntimeWarningr)rrr,rrrwarn_sometimess   z)Config._parseArgs..warn_sometimes)r'rI)NN)r getParserrbrS)rargv cfg_filesrr&rrr _parseArgss zConfig._parseArgsNcCs0|j}|dkrtj}t|dg}|||\}}t|dgrN|||j\}}||_|r^||_|jdk rz|jt |j|j dk rtj dkr|j |_ |j s| dd|_ |js| dg|_|js| dg|_|js| dg|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_||jsDdt_|j dk r\||j |jrrt |j|_|jrt!t"tj t |j|_t#$d |jnt#$d |j%|jrt!t"tj t |j|_t#$d |j|jr t!t"tj t |j|_t#$d |j|j&s,|j'(|||j')dS) zConfigure the nose running environment. Execute configure before collecting tests with nose.TestCollector to enable output capture and other features. Nfiles)Z NOSE_WHEREZNOSE_IGNORE_FILESZ NOSE_INCLUDEZ NOSE_EXCLUDETzIgnoring files matching %szIncluding tests matching %szExcluding tests matching %s)*rVrfrgetattrrrrsrwr6rr{ version_inforzrZrmrnreraruryrir~rcrdrorconfigureLogging byteCompiledont_write_bytecodeconfigureWherer`r^r_rkrlloginforj showPluginsrtrbegin)rrdocrVrrsrRrrrrsh       zConfig.configurec Cs|jr ddlm}||jdStd}|jr>t|j}n t|j}| |t d}d|_ d}|jrt j |j}|jD] }t|tjkr|j|krd}qn*|jD]"}t|tjkr|j|jkrd}q|s||tj}|jdkrd}n&|jd krtj}n|jd krtj}|||jrd d |jd D} | D]:} t | } | tj| jsF| dsF| |qFdS)aConfigure logging for nose, or optionally other packages. Any logger name may be set with the debug option, and that logger will be set to debug level and be assigned the same handler as the nose loggers, unless it already has a handler. r) fileConfigNz$%(name)s: %(levelname)s: %(message)snoseFTrcSsg|] }|r|qSrr)rrrrrrsz+Config.configureLogging..,)rologging.configrlogging Formatterrd FileHandler StreamHandlerrq setFormatter getLogger propagater[pathabspathhandlerstype baseFilenamerv addHandlerWARNINGryDEBUGINFOsetLevelrcsplitr) rrformathandlerloggerfoundZdebugLogAbsPathhZlvlZ debug_loggersZ logger_namelrrrr]sR                zConfig.configureLoggingcCsddlm}d|_t|}d}|D]}|jst|}|dkrHtd|td|||_|jr"t j t j |dr"td|||q"|st d td }|j|q"dS) zIConfigure the working directory or directories for the test run. r)add_pathNFz4Working directory '%s' not found, or not a directoryzSet working dir to %sz __init__.pyz5Working directory %s is a package; adding to sys.pathzUse of multiple -w arguments is deprecated and support may be removed in a future release. You can get the same behavior by passing directories without the -w argument on the command line, or by using the --tests argument in a configuration file.T)Z nose.importerrr}rr ValueErrorrrrar[rexistsrrDeprecationWarningrwr*)rrzrZwarnedrabs_pathrrrrs6  zConfig.configureWherecCs|j|jdS)z-Reset all config values to defaults. N)rrrrrrrdefaultszConfig.defaultc CsH|jr |jS|j}||}|jddddddd|jdd dd dd d|jd d dd|jdd|jddddddd|jddddddd|jdddd d!d"d#|jd$d%dd&d'd(d#|jd)dd*d+d,d#|jd-d.d/dd0d1d2|j|jd3|jd4dd5d6d7d8d9|jd:d;dd<|jd=d|jd>d?d|jd@dAdB|jdCdDdEd|jd@dFdB|jdGdHddId1dJd#|jdKdLddMd1dNd#|jdOdPddQd1dRd#|jdSdTddU|j dVd|jdWdXdYdZ|j d[d|jd\dd]|j d^d|jd_dYd]d`da|jdbd|j dcddde|jdfdgdhdddidjde|jdkdYdldmdnde|j ||||_|S)oz,Get the command line option parser. z-Vz --version store_trueversionFzOutput nose version and exit)actiondestrrz-pz --pluginsrz[Output list of available plugins and exit. Combine with higher verbosity for greater detailz-vz --verbosecountryzBe more verbose. [NOSE_VERBOSE]z --verbositystoreZ VERBOSITYrxz.Set verbosity; --verbosity=2 is the same as -v)rrmetavarrrz-qz--quiet store_constrzBe less verbose)rconstrrz-cz--configr*rZFILESzLoad configuration from config file(s). May be specified multiple times; in that case, all config files will be loaded and combined)rrrrz-wz--whererzZWHEREaLook for tests in this directory. May be specified multiple times. The first directory passed will be used as the working directory, in place of the current working directory, which is the default. Others will be added to the list of tests to execute. [NOSE_WHERE]z --py3wherer{ZPY3WHEREa-Look for tests in this directory under Python 3.x. Functions the same as 'where', but only applies if running under Python 3.x or above. Note that, if present under 3.x, this option completely replaces any directories specified with 'where', so the 'where' option becomes ineffective. [NOSE_PY3WHERE]z-mz--matchz --testmatchr`ZREGEXzFiles, directories, function names, and class names that match this regular expression are considered tests. Default: %s [NOSE_TESTMATCH])rrrrrz--testsrwNZNAMESzRun these tests (comma-separated list). This argument is useful mainly from configuration files; on the command line, just pass the tests to run as additional arguments with no switch.)rrrrrz-lz--debugrczActivate debug logging for one or more systems. Available debug loggers: nose, nose.importer, nose.inspector, nose.plugins, nose.result and nose.selector. Separate multiple names with a comma.z --debug-logrdFILEz5Log debug messages to this file (default: sys.stderr))rrrrrz--logging-configz --log-configrozQLoad logging config from this file -- bypasses all other logging config settings.z-Iz--ignore-filesrmaCompletely ignore any file that matches this regular expression. Takes precedence over any other settings or plugins. Specifying this option will replace the default setting. Specify this option multiple times to add more regular expressions [NOSE_IGNORE_FILES]z-ez --excluderezs<    d\