Your IP : 216.73.216.61


Current Path : /opt/alt/python35/lib/python3.5/site-packages/nose/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/nose/__pycache__/config.cpython-35.pyc



�^�]�b�@sddlZddlZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
mZeje�ZddgZdd	gZd
dfZedd
edd�Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�Zdd�Zdd�Zd d!�Z dS)"�N)�OptionParser)�absdir�tolist)�	NoPlugins)�warn�filterwarnings�help�verbosez	~/.nosercz
~/nose.cfg�win32�cli�always�category�modulez(.*\.)?nose\.configc@seZdZdd�ZdS)�NoSuchOptionErrorcCstj||�||_dS)N)�	Exception�__init__�name)�selfr�r�</opt/alt/python35/lib/python3.5/site-packages/nose/config.pyr szNoSuchOptionError.__init__N)�__name__�
__module__�__qualname__rrrrrrsrc@seZdZdS)�ConfigErrorN)rrrrrrrr%src@s|eZdZdZdddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�ConfiguredDefaultsOptionParserz@
    Handler for options from commandline and config files.
    Ncs^||_||_�dkr*|jj��|_|dkrQ�fdd�}||_dS)Ncs
�|�S)Nr)�msg�kw)�errorrr�<lambda>4sz9ConfiguredDefaultsOptionParser.__init__.<locals>.<lambda>)�_parser�_config_sectionr�_error�_file_error)r�parserZconfig_sectionr�
file_errorr)rrr-s			z'ConfiguredDefaultsOptionParser.__init__cCsXg}|j|j�krTx6|j|j�D]"\}}|j|||f�q.W|S)N)r �sections�items�append)r�cfg�filename�configr�valuerrr�
_configTuples7s
z,ConfiguredDefaultsOptionParser._configTuplescCs�g}x�|D]�}tj�}y|j|�WnDtjk
rv}z!td|t|�f��WYdd}~XnX|j|j||��q
W|S)Nz Error reading config file %r: %s)�configparser�RawConfigParser�read�Errorr�str�extendr,)r�	filenamesr*r)r(�excrrr�_readFromFilenames>s
)z1ConfiguredDefaultsOptionParser._readFromFilenamescCs�tj�}y
|j}Wntk
r3d}YnXy|j|�WnDtjk
r�}z!td|t|�f��WYdd}~XnX|j||�S)Nz<???>z Error reading config file %r: %s)	r-r.r�AttributeError�readfpr0rr1r,)r�fhr(r)r4rrr�_readFromFileObjectJs

)z2ConfiguredDefaultsOptionParser._readFromFileObjectcCsoy|jWnHtk
rU|}t|t�r<|g}n|}|j|�}YnX|}|j|�}|S)N)�readliner6�
isinstancer1r5r9)r�config_filesZfilename_or_filenamesr3r*r8rrr�_readConfigurationWs
z1ConfiguredDefaultsOptionParser._readConfigurationcCsNd|}|j|�}|dkr4t|��n|j||||�dS)Nz--)Z
get_optionr�process)rrr+�valuesr#Zopt_str�optionrrr�_processConfigValuefs

z2ConfiguredDefaultsOptionParser._processConfigValuec	Csx�|D]�\}}}|tkr%qy|j||||�Wqtk
r�}z+|jd||jfd|d|�WYdd}~Xqtjk
r�}zMt|�jd|t	|�d�}|jd||fd|d|�WYdd}~XqXqWdS)Nz/Error reading config file %r: no such option %rrr)z--�z Error reading config file %r: %s)
�option_blacklistrArr"r�optparseZOptionValueErrorr1�replace�repr)	rr#r*r?rr+r)r4rrrr�_applyConfigurationToValuesns%	
z:ConfiguredDefaultsOptionParser._applyConfigurationToValuescCs�|jj�}y|j|�}Wn8tk
r\}z|jt|��WYdd}~XnVXy|j|j||�Wn8tk
r�}z|jt|��WYdd}~XnX|jj||�S)N)rZget_default_valuesr=rr!r1rG�
parse_args)r�argsr<r?r*r4rrr�parseArgsAndConfigFiless&&z6ConfiguredDefaultsOptionParser.parseArgsAndConfigFiles)rrr�__doc__rr,r5r9r=rArGrJrrrrr)s

rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�ZeZd
d�Z	ddd
d�Z
dd�Zdd�Zdd�Z
ddd�Zddd�Zdd�Zdd�Zdd�Zdd �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|jdi�|_}f|_|jddtj�|_tj|j�|_	|jdd�|_
d|_|jd�|_|jd�|_
d|_d|_|jd	tjtk�|_d
ddg|_tttj|j��|_d|_d|_tj|_t�|_d|_t�|_ d|_!d|_"|jdd�|_#tj|_$g|_%t&|jdd��|_'f|_(f|_)tj*�|_+d|_,d|_-t.|_/d|_0|j1j2�|_3|j4|�|j1j2�|_5dS)N�envZNOSE_TESTMATCHz(?:^|[\b_\.%s-])[Tt]estZNOSE_NOPATHFZ	nosetestsZ
NOSE_DEBUGZNOSE_DEBUG_LOGZNOSE_INCLUDE_EXEz^\.z^_z^setup\.py$�lib�srcTZ	NOSE_STOPZNOSE_VERBOSErB)rNrO)6�poprMrI�get�os�sep�testMatchPat�re�compile�	testMatch�addPaths�
configSection�debug�debugLog�excludeZgetTestCaseNamesCompat�sys�platform�exe_allowed_platforms�
includeExe�ignoreFilesDefaultStrings�list�map�ignoreFiles�include�
loggingConfig�stderr�	logStream�	NoOptions�optionsr#r�pluginsZsrcDirsZ	runOnInit�stopOnError�stream�	testNames�int�	verbosity�where�py3where�getcwd�
workingDir�traverseNamespace�firstPackageWinsr�parserClass�worker�__dict__�copy�_default�update�_orig)rrrMrrrr�sN																		
zConfig.__init__cCsF|jj�}|d=|d=|d=|d=|d=|jj|d<|S)Nrmr}r{rMrhrk)ryrzrk�	__class__)r�staterrr�__getstate__�szConfig.__getstate__cCsw|jd�}|j|�d|_|�|_|jj�|j�}|jj|i�|jj|j|�dS)NrkT)	rPr|rxrk�loadPluginsrw�
addOptions�	configurerj)rrZ	pluginclsZdummy_parserrrr�__setstate__�s
	
zConfig.__setstate__csf|jj��i�d<dd�t�j��D�}|j�ddj�fdd�|D��S)NrMcSs%g|]}|jd�s|�qS)�_)�
startswith)�.0�krrr�
<listcomp>�s	z#Config.__repr__.<locals>.<listcomp>z
Config(%s)z, cs$g|]}d|�|f�qS)z%s=%rr)r�r�)�drrr��s	)ryrzrb�keys�sort�join)rr�r)r�r�__repr__�s

zConfig.__repr__csPdd�fdd�}t�j��jd|�}|j|dd�|�S)NcsTt�jd�rD�jj|�rDd||f}t|t�nt|��dS)N�excludedOptionzDOption %r in config file %r ignored: excluded by runtime environment)�hasattrrkr�r�RuntimeWarningr)rrr))rrr�warn_sometimess
z)Config._parseArgs.<locals>.warn_sometimesr$rB)r�	getParserrYrJ)r�argv�	cfg_filesr�r#r)rr�
_parseArgss	zConfig._parseArgsNcCs|j}|dkrtj}t|dg�}|j||�\}}t|dg�ru|j||j�\}}||_|r�||_|jdk	r�|jjt	|j��|j
dk	r�tjdkr�|j
|_|js�|j
dd�|_|js|j
dg�|_|js9|j
dg�|_|jsW|j
dg�|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j�|js�dt_|jdk	r�|j|j�|jrtj |j�|_|jr_t!t"tj t	|j���|_t#j$d	|j�nt#j$d	|j%�|jr�t!t"tj t	|j���|_t#j$d
|j�|jr�t!t"tj t	|j���|_t#j$d|j�|j&s|j'j(||�|j'j)�dS)
z�Configure the nose running environment. Execute configure before
        collecting tests with nose.TestCollector to enable output capture and
        other features.
        N�files�Z
NOSE_WHEREZNOSE_IGNORE_FILESZNOSE_INCLUDEZNOSE_EXCLUDETzIgnoring files matching %szIncluding tests matching %szExcluding tests matching %s)r�)*rMr]r��getattrr�r�rjrnr2rrr�version_inforqrQrdrer\rXrlrpr`rurZr[rfrv�configureLogging�byteCompile�dont_write_bytecode�configureWhererWrUrVrbrc�log�infora�showPluginsrkr��begin)rr��docrMr�rjrIrrrr�sh								
				$	$	$	zConfig.configurecCs+|jr*ddlm}||j�dStjd�}|jrWtj|j�}ntj|j�}|j	|�tj
d�}d|_d}|jr�tj
j|j�}x|jD]0}t|�tjkr�|j|kr�d}q�WnAx>|jD]3}t|�tjkr�|j|jkr�d}q�W|sG|j|�tj}|jdkrhd}n3|jd	kr�tj}n|jd
kr�tj}|j|�|jr'dd�|jjd
�D�}	xT|	D]L}
tj
|
�}|jtj�|jr�|
jd�r�|j|�q�WdS)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)s�noseFT��r�cSsg|]}|r|�qSrr)r�rrrrr��s	z+Config.configureLogging.<locals>.<listcomp>�,)rfZlogging.configr��logging�	Formatterr[�FileHandler�
StreamHandlerrh�setFormatter�	getLogger�	propagaterR�path�abspath�handlers�type�baseFilenamerm�
addHandler�WARNINGrp�DEBUG�INFO�setLevelrZ�splitr�)rr��format�handler�logger�foundZdebugLogAbsPath�hZlvlZ
debug_loggers�logger_name�lrrrr�]sN	
	
		


			
	
zConfig.configureLoggingcCs�ddlm}d|_t|�}d}x�|D]�}|js�t|�}|dkritd|��tjd|�||_|jr2t	j
jt	j
j|d��r2tjd|�||�q2|s�t
d	t�d
}|jj|�q2WdS)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.pathz�Use 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.importerr�rtrr�
ValueErrorr�r�rXrRr��existsr�r�DeprecationWarningrnr')rrqr�Zwarnedr�Zabs_pathrrrr��s.	
	
		!	
zConfig.configureWherecCs|jj|j�dS)z-Reset all config values to defaults.
        N)ryr|r{)rrrr�default�szConfig.defaultcCs|jr|jS|j}|j|�}|jddddddddd	d
�|jdddddd
ddd	d�|jddddddd|jd	d�|jdddddddddd	d�|jddddddddd	d �|jd!d"dd#dd$dd%d	d&�|jd'd(dd#dd)dd*d	d+�|jd,dd#dd-dd.d	d/�|jd0d1d2dddd3dd4d	d5|jd|j�|jd6dddd7dd8dd9d	d:�|jd;d<dddd=d|jd	d>�|jd?dd@ddd|jddAd	dB�|jdCdDddEddd|jddAd	dF�|jdGdHdd#ddIdd4d	dJ�|jdKdLdd#ddMdd4d	dN�|jdOdPdd#ddQdd4d	dR�|jdSdTddddUd|j	d	dV�|jdWdXddYddZd|j
d	d[�|jd\dddd]d|jd	d^�|jd_ddYdd]d	d`�|jdaddd|jddbd	dc�|jdddedfddddddgd	dh�|jdiddYddjddkd	dl�|j
j�|j|�||_|S)mz,Get the command line option parser.
        z-Vz	--version�action�
store_true�dest�versionr�FrzOutput nose version and exitz-pz	--pluginsr�z[Output list of available plugins and exit. Combine with higher verbosity for greater detailz-vz	--verbose�countrpzBe more verbose. [NOSE_VERBOSE]z--verbosity�store�metavarZ	VERBOSITYr�roz.Set verbosity; --verbosity=2 is the same as -vz-qz--quiet�store_const�constrzBe less verbosez-cz--configr'r�ZFILESz�Load configuration from config file(s). May be specified multiple times; in that case, all config files will be loaded and combinedz-wz--whererqZWHEREaLook 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
--py3whererrZPY3WHEREa-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--testmatchrWZREGEXz�Files, directories, function names, and class names that match this regular expression are considered tests.  Default: %s [NOSE_TESTMATCH]z--testsrnNZNAMESz�Run 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.z-lz--debugrZz�Activate 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-logr[ZFILEz5Log debug messages to this file (default: sys.stderr)z--logging-configz--log-configrfzQLoad logging config from this file -- bypasses all other logging config settings.z-Iz--ignore-filesrdaCompletely 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	--excluder\z<Don't run tests that match regular expression [NOSE_EXCLUDE]z-iz	--includerez�This regular expression will be applied to files, directories, function names, and class names for a chance to include additional tests that do not match TESTMATCH.  Specify this option multiple times to add more regular expressions [NOSE_INCLUDE]z-xz--stoprlz3Stop running tests after the first error or failurez-Pz--no-path-adjustment�store_falserXzCDon't make any changes to sys.path when loading tests [NOSE_NOPATH]z--exer`z�Look for tests in python modules that are executable. Normal behavior is to exclude executable modules, since they may not be import-safe [NOSE_INCLUDE_EXE]z--noexezoDO NOT look for tests in python modules that are executable. (The default on the windows platform is to do so.)z--traverse-namespaceruz8Traverse through all path entries of a namespace packagez--first-package-winsz--first-pkg-winsz--1st-pkg-winsrvz�nose's importer will normally evict a package from sys.modules if it sees a package with the same name in a different location. Set this option to disable that behavior.z--no-byte-compileTr�ziPrevent nose from byte-compiling the source into .pyc files while nose is scanning for and running tests.)r#rMrw�
add_optionrprTrZr[rfrlrXr`rurkr��
pluginOpts)rr�rMr#rrrr��s�				


				

	zConfig.getParsercCs|j|�j�S)z*Return the generated help message
        )r��format_help)rr�rrrrTszConfig.helpcCs|jj||j�dS)N)rkr�rM)rr#rrrr�YszConfig.pluginOptscCs|jj|j�dS)N)ryr|r})rrrr�reset\szConfig.resetcCs
|jj�S)N)ryrz)rrrr�todict_sz
Config.todictcCs|jj|�dS)N)ryr|)rr�rrrr|bsz
Config.update)rrrrKrr�r�r��__str__r�r�r�r�r�r�rr�r�r�r|rrrrrL�s"%+	N;�rLc@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)riz9Options container that returns None for all options.
    cCsiS)Nr)rrrrr�iszNoOptions.__getstate__cCsdS)Nr)rrrrrr�lszNoOptions.__setstate__cCsfS)Nr)rrrr�__getnewargs__oszNoOptions.__getnewargs__cCsdS)NFr)rrrr�__bool__rszNoOptions.__bool__N)rrrrKr�r�r�r�rrrrrifs
ricCs.tttjjtttjjt����S)z2Return path to any existing user config files
    )rb�filterrRr�r�rc�
expanduserr<rrrr�user_config_filesvsr�cCs*t�}tjjd�r&|dgS|S)zlReturn path to any existing user config files, plus any setup.cfg
    in the current working directory.
    z	setup.cfg)r�rRr�r�)�userrrr�all_config_files}s	r�c	CsR|dkrdS|dkr dSt|�}t|�dkrBdS|j�dkS)z(Does the value look like an on/off flag?rBTrFr��1�0�F�T�TRUE�FALSE�ON�OFF)r�r�r�r�r�r�r�r�)r1�len�upper)�valrrr�flag�sr�cCst|�j�dkS)Nr�r�r�r�)r�r�r�r�)r1r�)r�rrr�_bool�sr�)!r�rDrRrUr]r-rZ	nose.utilrrZnose.plugins.managerr�warningsrrr�rr�rCr<r_r�rrr�objectrrLrir�r�r�r�rrrr�<module>s4	d��