
K9Qc           @   sW  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m Z m	 Z	 d  d l
 m Z d  d l m Z e  j e  Z d d g Z d d	 g Z d
 d f Z d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d   Z d   Z d   Z d   Z d S(   iN(   t   OptionParser(   t   absdirt   tolist(   t	   NoPlugins(   t   warnt   helpt   verboses	   ~/.nosercs
   ~/nose.cfgt   win32t   clit   NoSuchOptionErrorc           B   s   e  Z d    Z RS(   c         C   s   t  j |  |  | |  _ d  S(   N(   t	   Exceptiont   __init__t   name(   t   selfR   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR      s    (   t   __name__t
   __module__R   (    (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR	      s   t   ConfigErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR   #   s   t   ConfiguredDefaultsOptionParserc           B   s\   e  Z d  Z d	 d	 d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(
   s@   
    Handler for options from commandline and config files.
    c            sa   | |  _  | |  _   d  k r- |  j  j   n    |  _ | d  k rT   f d   } n  | |  _ d  S(   Nc            s
     |   S(   N(    (   t   msgt   kw(   t   error(    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   <lambda>2   s    (   t   _parsert   _config_sectiont   NoneR   t   _errort   _file_error(   R   t   parsert   config_sectionR   t
   file_error(    (   R   s/   /sys/lib/python2.7/site-packages/nose/config.pyR   +   s    			c         C   s[   g  } |  j  | j   k rW x9 | j |  j   D]" \ } } | j | | | f  q. Wn  | S(   N(   R   t   sectionst   itemst   append(   R   t   cfgt   filenamet   configR   t   value(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   _configTuples5   s
    c         C   s   g  } xy | D]q } t  j   } y | j |  Wn2 t  j k
 rd } t d | t |  f   n X| j |  j | |   q W| S(   Ns    Error reading config file %r: %s(   t   ConfigParsert   RawConfigParsert   readt   ErrorR   t   strt   extendR%   (   R   t	   filenamesR#   R"   R!   t   exc(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   _readFromFilenames<   s    c         C   s   t  j   } y | j } Wn t k
 r2 d } n Xy | j |  Wn2 t  j k
 rx } t d | t |  f   n X|  j | |  S(   Ns   <???>s    Error reading config file %r: %s(	   R&   R'   R   t   AttributeErrort   readfpR)   R   R*   R%   (   R   t   fhR!   R"   R-   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   _readFromFileObjectH   s    
c         C   sn   y | j  WnG t k
 rT | } t | t  r< | g } n | } |  j |  } n X| } |  j |  } | S(   N(   t   readlineR/   t
   isinstancet
   basestringR.   R2   (   R   t   config_filest   filename_or_filenamesR,   R#   R1   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   _readConfigurationU   s    c         C   sN   d | } | j  |  } | d  k r4 t |   n | j | | | |  d  S(   Ns   --(   t
   get_optionR   R	   t   process(   R   R   R$   t   valuesR   t   opt_strt   option(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   _processConfigValued   s
    
c   	      C   s   x | D] \ } } } | t  k r( q n  y |  j | | | |  Wq t k
 r} } |  j d | | j f d | d | q t j k
 r } t |  j d | t	 |  d  } |  j d | | f d | d | q Xq Wd  S(   Ns/   Error reading config file %r: no such option %rR   R"   s   --i   s    Error reading config file %r: %s(
   t   option_blacklistR>   R	   R   R   t   optparset   OptionValueErrorR*   t   replacet   repr(	   R   R   R#   R;   R   R$   R"   R-   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   _applyConfigurationToValuesl   s    %	c         C   s   |  j  j   } y |  j |  } Wn& t k
 rJ } |  j t |   nD Xy |  j |  j  | |  Wn& t k
 r } |  j t |   n X|  j  j | |  S(   N(   R   t   get_default_valuesR8   R   R   R*   RD   t
   parse_args(   R   t   argsR6   R;   R#   R-   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   parseArgsAndConfigFiles}   s    N(   R   R   t   __doc__R   R   R%   R.   R2   R8   R>   RD   RH   (    (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR   '   s   
						t   Configc           B   s   e  Z d  Z d   Z d   Z d   Z d   Z e Z d   Z d d d  Z
 d   Z d   Z d	   Z d d
  Z d d  Z d   Z d   Z d   Z d   Z RS(   sD  nose 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
    c         K   s   | j  d i   |  _ } d |  _ | j d d t j  |  _ t j |  j  |  _	 | j d t
  |  _ d |  _ | j d  |  _ | j d  |  _ d  |  _ t
 |  _ | j d t j t k  |  _ d	 d
 d g |  _ t t j |  j  |  _ d  |  _ d  |  _ t j |  _ t   |  _ d  |  _ t    |  _! d |  _" t# |  _$ | j d t
  |  _% t j |  _& g  |  _' t( | j d d   |  _) d |  _* d |  _+ t j,   |  _- t
 |  _. t
 |  _/ t0 |  _1 t
 |  _2 |  j3 j4   |  _5 |  j6 |  |  j3 j4   |  _7 d  S(   Nt   envt   NOSE_TESTMATCHs   (?:^|[\b_\.%s-])[Tt]estt   NOSE_NOPATHt	   nosetestst
   NOSE_DEBUGt   NOSE_DEBUG_LOGt   NOSE_INCLUDE_EXEs   ^\.s   ^_s   ^setup\.py$t   libt   srct	   NOSE_STOPt   NOSE_VERBOSEi   (    (   s   libs   src(    (    (8   t   popRK   RG   t   gett   ost   sept   testMatchPatt   ret   compilet	   testMatcht   Falset   addPathst   configSectiont   debugt   debugLogR   t   excludet   getTestCaseNamesCompatt   syst   platformt   exe_allowed_platformst
   includeExet   ignoreFilesDefaultStringst   mapt   ignoreFilest   includet   loggingConfigt   stderrt	   logStreamt	   NoOptionst   optionsR   R   t   pluginst   srcDirst   Truet	   runOnInitt   stopOnErrort   streamt	   testNamest   intt	   verbosityt   wheret   py3wheret   getcwdt
   workingDirt   traverseNamespacet   firstPackageWinsR    t   parserClasst   workert   __dict__t   copyt   _defaultt   updatet   _orig(   R   R   RK   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR      sN    																		c         C   sF   |  j  j   } | d =| d =| d =| d =| d =|  j j | d <| S(   NRw   R   R   RK   Ro   Rr   (   R   R   Rr   t	   __class__(   R   t   state(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   __getstate__   s    c         C   sw   | j  d  } |  j |  t |  _ |   |  _ |  j j   |  j   } |  j j | i   |  j j |  j	 |   d  S(   NRr   (
   RV   R   Rt   R   Rr   t   loadPluginsR   t
   addOptionst	   configureRq   (   R   R   t	   pluginclst   dummy_parser(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   __setstate__   s    	c         C   s   |  j  j   } i  | d <g  | j   D] } | j d  s& | ^ q& } | j   d d j g  | D] } d | | | f ^ qa  S(   NRK   t   _s
   Config(%s)s   , s   %s=%r(   R   R   t   keyst
   startswitht   sortt   join(   R   t   dt   kR   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   __repr__   s    

c            sG   d  d    f d  } t   j     j d | } | j | d |  S(   Nc            sT   t    j d  rD   j j |  rD d | | f }  t |  t  n t |    d  S(   Nt   excludedOptionsD   Option %r in config file %r ignored: excluded by runtime environment(   t   hasattrRr   R   R   t   RuntimeWarningR   (   R   R   R"   (   R   (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   warn_sometimes   s    R   i   (   R   R   t	   getParserR`   RH   (   R   t   argvt	   cfg_filesR   R   (    (   R   s/   /sys/lib/python2.7/site-packages/nose/config.pyt
   _parseArgs   s    	c         C   s=  |  j  } | d
 k r! t j } n  t |  d g   } |  j | |  \ } } t | d g   r{ |  j | | j  \ } } n  | |  _ | r | |  _ n  | j d
 k	 r |  j j	 t
 | j   n  | j d
 k	 r t j d k r | j | _ q n  | j s| j d d
  | _ n  | j s3| j d g   | _ n  | j sT| j d g   | _ n  | j su| j d g   | _ n  | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ |  j   | j s t t _ n  | j d
 k	 r"|  j | j  n  | j  rCt! j" | j   |  _  n  | j rt# t! j" t
 | j   |  _ t$ j% d | j  n t$ j% d |  j&  | j rt# t! j" t
 | j   |  _ t$ j% d | j  n  | j rt# t! j" t
 | j   |  _ t$ j% d	 | j  n  | j' s9|  j( j) | |   |  j( j*   n  d
 S(   s   Configure the nose running environment. Execute configure before
        collecting tests with nose.TestCollector to enable output capture and
        other features.
        t   filesi   t
   NOSE_WHEREt   NOSE_IGNORE_FILESt   NOSE_INCLUDEt   NOSE_EXCLUDEs   Ignoring files matching %ss   Including tests matching %ss   Excluding tests matching %sN(   i   (+   RK   R   Re   R   t   getattrR   R   Rq   Rx   R+   R   R|   t   version_infoR{   RW   Rk   Rl   Rc   R_   Rv   Rz   Rh   R   Ra   Rb   Rm   R   t   configureLoggingt   byteCompileRt   t   dont_write_bytecodet   configureWhereR]   R[   R\   Rj   t   logt   infoRi   t   showPluginsRr   R   t   begin(   R   R   t   docRK   R   Rq   RG   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR     sh    						
						c         C   sI  |  j  r* d d l m } | |  j   d St j d  } |  j rW t j |  j  } n t j |  j  } | j	 |  t j
 d  } d | _ t } |  j r t j j |  j  } x | j D]3 } t |  t j k r | j | k r t } q q WnD xA | j D]6 } t |  t j k r | j |  j k r t } q q W| sP| j |  n  t j } |  j d k rqd } n6 |  j d k rt j } n |  j d	 k rt j } n  | j |  |  j rEg  |  j j d
  D] }	 |	 r|	 ^ q}
 xZ |
 D]O } t j
 |  } | j t j  | j r| j d  r| j |  qqWn  d S(   s  Configure 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.
        i(   t
   fileConfigNs$   %(name)s: %(levelname)s: %(message)st   nosei    i   i   i   t   ,(   Rm   t   logging.configR   t   loggingt	   FormatterRb   t   FileHandlert   StreamHandlerRo   t   setFormattert	   getLoggert	   propagateR^   RX   t   patht   abspatht   handlerst   typet   baseFilenameRt   Rw   t
   addHandlert   WARNINGRz   t   DEBUGt   INFOt   setLevelRa   t   splitR   (   R   R   t   formatt   handlert   loggert   foundt   debugLogAbsPatht   ht   lvlR   t   debug_loggerst   logger_namet   l(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR   [  sP    							c         C   s  d d l  m } d |  _ t |  } t } x | D] } |  j s t |  } | d k rl t d |   n  t j	 d |  | |  _ |  j
 r2 t j j t j j | d   r2 t j	 d |  | |  q2 q2 n  | s t d t  n  |  j j |  q2 Wd S(	   sI   Configure the working directory or directories for the test run.
        i(   t   add_paths2   Working directory %s not found, or not a directorys   Set working dir to %ss   __init__.pys5   Working directory %s is a package; adding to sys.paths   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.N(   t   nose.importerR   R   R~   R   R^   R   t
   ValueErrorR   R   R_   RX   R   t   existsR   R   t   DeprecationWarningRx   R    (   R   R{   R   t   warnedR   t   abs_path(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR     s,    				!	
c         C   s   |  j  j |  j  d S(   s-   Reset all config values to defaults.
        N(   R   R   R   (   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   default  s    c         C   s  |  j  r |  j  S|  j } |  j |  } | j d d d d d d d t d d	 | j d
 d d d d d d t d d | j d d d d d d d |  j d d | j d d d d d d d d d d d | j d d d d d d d d d d | j d  d! d d" d d# d d$ d d% | j d& d' d d" d d( d d) d d* | j d+ d d" d d, d d- d d. | j d/ d0 d1 d d d d2 d d3 d d4 |  j d |  j | j d5 d d d d6 d dj d d7 d d8 | j d9 d: d d d d; d |  j d d< | j d= d d> d d d |  j	 d d? d d@ | j dA dB d dC d d d |  j
 d d? d dD | j dE dF d d" d dG d d3 d dH | j dI dJ d d" d dK d d3 d dL | j dM dN d d" d dO d d3 d dP | j dQ dR d d d dS d |  j d dT | j dU dV d dW d dX d |  j d dY | j dZ d d d d[ d |  j d d\ | j d] d dW d d[ d d^ | j d_ d d d |  j d d` d da | j db dc dd d d d t d de d df | j dg d dW d t d dh d di |  j j   |  j |  | |  _  | S(k   s,   Get the command line option parser.
        s   -Vs	   --versiont   actiont
   store_truet   destt   versionR   R   s   Output nose version and exits   -ps	   --pluginsR   s[   Output list of available plugins and exit. Combine with higher verbosity for greater details   -vs	   --verboset   countRz   s   Be more verbose. [NOSE_VERBOSE]s   --verbosityt   storet   metavart	   VERBOSITYR   Ry   s.   Set verbosity; --verbosity=2 is the same as -vs   -qs   --quiett   store_constt   consti    s   Be less verboses   -cs   --configR    R   t   FILESs   Load configuration from config file(s). May be specified multiple times; in that case, all config files will be loaded and combineds   -ws   --whereR{   t   WHEREs  Look 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]s
   --py3whereR|   t   PY3WHEREs-  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]s   -ms   --matchs   --testmatchR]   t   REGEXs   Files, directories, function names, and class names that match this regular expression are considered tests.  Default: %s [NOSE_TESTMATCH]s   --testsRx   t   NAMESs   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.s   -ls   --debugRa   s   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.s   --debug-logRb   t   FILEs5   Log debug messages to this file (default: sys.stderr)s   --logging-configs   --log-configRm   sQ   Load logging config from this file -- bypasses all other logging config settings.s   -Is   --ignore-filesRk   s  Completely 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]s   -es	   --excludeRc   s<   Don't run tests that match regular expression [NOSE_EXCLUDE]s   -is	   --includeRl   s   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]s   -xs   --stopRv   s3   Stop running tests after the first error or failures   -Ps   --no-path-adjustmentt   store_falseR_   sC   Don't make any changes to sys.path when loading tests [NOSE_NOPATH]s   --exeRh   s   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]s   --noexeso   DO NOT look for tests in python modules that are executable. (The default on the windows platform is to do so.)s   --traverse-namespaceR   s8   Traverse through all path entries of a namespace packages   --first-package-winss   --first-pkg-winss   --1st-pkg-winsR   s   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.s   --no-byte-compileR   si   Prevent nose from byte-compiling the source into .pyc files while nose is scanning for and running tests.N(   R   RK   R   t
   add_optionR^   Rz   RZ   R   Ra   Rb   Rm   Rv   R_   Rh   R   Rt   Rr   R   t
   pluginOpts(   R   R   RK   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR     s    				

					c         C   s   |  j  |  j   S(   s*   Return the generated help message
        (   R   t   format_help(   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR   Q  s    c         C   s   |  j  j | |  j  d  S(   N(   Rr   R   RK   (   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR   V  s    c         C   s   |  j  j |  j  d  S(   N(   R   R   R   (   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   resetY  s    c         C   s   |  j  j   S(   N(   R   R   (   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   todict\  s    c         C   s   |  j  j |  d  S(   N(   R   R   (   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR   _  s    N(   R   R   RI   R   R   R   R   t   __str__R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyRJ      s"   %	+					N	;					Rp   c           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s9   Options container that returns None for all options.
    c         C   s   i  S(   N(    (   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR   f  s    c         C   s   d  S(   N(    (   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyR   i  s    c         C   s   d S(   N(    (    (   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   __getnewargs__l  s    c         C   s   d  S(   N(   R   (   R   t   attr(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   __getattr__o  s    c         C   s   t  S(   N(   R^   (   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   __nonzero__r  s    (   R   R   RI   R   R   R   R   R   (    (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyRp   c  s   				c           C   s"   t  t j j t t j j t   S(   s2   Return path to any existing user config files
    (   t   filterRX   R   R   Rj   t
   expanduserR6   (    (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   user_config_filesv  s    c          C   s*   t    }  t j j d  r& |  d g S|  S(   sl   Return path to any existing user config files, plus any setup.cfg
    in the current working directory.
    s	   setup.cfg(   R   RX   R   R   (   t   user(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   all_config_files}  s    	c      	   C   sR   |  d k r t  S|  d k r  t St |   }  t |   d k rB t S|  j   d k S(   s(   Does the value look like an on/off flag?i   i    i   t   1t   0t   Ft   Tt   TRUEt   FALSEt   ONt   OFF(   R   R   R   R   R   R   R   R   (   Rt   R^   R*   t   lent   upper(   t   val(    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   flag  s    c         C   s   t  |   j   d k S(   NR   R   R   R   (   R   R   s   TRUEs   ON(   R*   R  (   R  (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   _bool  s    (   R   R@   RX   R[   Re   R&   R    t	   nose.utilR   R   t   nose.plugins.managerR   t   warningsR   R   R   R   R?   R6   Rg   R
   R	   R   t   objectR   RJ   Rp   R   R   R  R  (    (    (    s/   /sys/lib/python2.7/site-packages/nose/config.pyt   <module>   s0   	d 			