Changeset 28

Show
Ignore:
Timestamp:
Wed Apr 26 21:38:54 2006
Author:
jpellerin
Message:

r900@Jason-Pellerins-Computer: jhp | 2006-04-25 21:11:38 -0500
Work on docs

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/nose/suite.py

    r26 r28  
      1 """nose TestSuite subclasses that implement lazy test collection for modules,  
      2 classes and directories, and provide suite-level fixtures (setUp/tearDown  
      3 methods).  
      4 """  
    1 5 import logging  
    2 6 import sys  
     
    11 15  
    12 16 class LazySuite(unittest.TestSuite):  
    13    
      17     """Generator-based test suite. Pass a callable that returns an iterable of  
      18     tests, and a nose.config.Config. Also provides hooks (setUp and tearDown)  
      19     for suite-level fixtures.  
      20     """  
    14 21     # _exc_info_to_string needs this property  
    15 22     failureException = unittest.TestCase.failureException  
     
    65 72  
    66 73 class GeneratorMethodTestSuite(LazySuite):  
    67        
      74     """Test suite for test methods that are generators.  
      75     """  
    68 76     def __init__(self, cls, method):  
    69 77         self.cls = cls  
     
    88 96              
    89 97 class TestClass(LazySuite):  
    90       """Collects tests from a class.  
    91    
    92       FIXME docs  
      98     """Lazy suite that collects tests from a class.  
    93 99     """  
    94 100     def __init__(self, loadtests, conf, cls):  
     
    108 114  
    109 115 class TestDir(LazySuite):  
    110       """Test collector that collects tests from a directory.  
      116     """Lazy suite that collects tests from a directory.  
    110 116     """  
    111 117     def __init__(self, loadtests, conf, path, module=None, importPath=None):  
     
    127 133              
    128 134 class TestModule(LazySuite):  
    129       """Test collector that collects tests from modules and packages.  
      135     """Lazy suite that collects tests from modules and packages.  
    129 135  
    130       This collector collects module members that match the testMatch  
      136     This suite collects module members that match the testMatch  
    130 136     regular expression. For packages, it also collects any modules or  
    131 137     packages found in the package __path__ that match testMatch. For  
  • trunk/nose/plugins/base.py

    r26 r28  
    354 354         directory, false if you do not, and None if you don't care.  
    355 355  
    356           FIXME: WARNING: Hook not implemented!  
    357            
    358 356         Parameters:  
    359 357          * dirname:  
  • trunk/nose/case.py

    r26 r28  
      1 """nose unittest.TestCase subclasses. It is not necessary to subclass these  
      2 classes when writing tests; they are used internally by nose.loader.TestLoader  
      3 to create test cases from test functions and methods in test classes.  
      4 """  
    1 5 import logging  
    2 6 import unittest  
  • trunk/nose/util.py

    r23 r28  
    1   """Implements utility functions and classes used by nose.core  
      1 """Utility functions and classes used by nose internally.  
    1 1 """  
    2 2 import inspect  
  • trunk/nose/result.py

    r26 r28  
      1 """Test result handlers. Base class (Result) implements plugin handling,  
      2 output capture, and assert introspection, and handles deprecated and skipped  
      3 tests. TextTestResult is a drop-in replacement for unittest._TextTestResult  
      4 that uses the capabilities in Result.  
      5 """  
    1 6 import inspect  
    2 7 import logging  
     
    131 136         printed with errors and failures, but don't cause the test run as a  
    132 137         whole to be considered non-successful.  
    133       """  
    134        
      138     """     
    135 139     def __init__(self, stream, descriptions, verbosity, conf):         
    136 140         self.deprecated = []  
  • trunk/nose/__init__.py

    r27 r28  
    248 248 ------------------  
    249 249  
    250   To report bugs, ask questions, or request features, please email the author at  
      250 To report bugs, ask questions, or request features, please use the trac  
      251 instance provided by the great folks at python hosting, here:  
      252 http://nose.python-hosting.org. Or, email the author at  
    251 253 jpellerin+nose at gmail dot com. Patches are welcome!  
    252 254  
  • trunk/nose/exc.py

    r7 r28  
      1 """Exceptions for marking tests as skipped or deprecated.  
      2 """  
    1 3 class DeprecatedTest(Exception):  
      4     """Raise this exception to mark a test as deprecated.  
      5     """  
    2 6     pass  
    3 7  
    4 8 class SkipTest(Exception):  
      9     """Raise this exception to mark a test as skipped.  
      10     """  
    5 11     pass  
  • trunk/nose/selector.py

    r26 r28  
    10 10  
    11 11 class Selector(object):  
    12       """FIXME docs for selector  
      12     """Core test selector. Examines test candidates and determines whether,  
      13     given the specified configuration, the test candidate should be selected  
      14     as a test.  
    13 15     """  
    14 16     def __init__(self, conf):  
  • trunk/nose/importer.py

    r21 r28  
    1 1 """Implements an importer that looks only in specific path (ignoring  
    2   sys.path), and uses a per-path cache in addition to sys.odules  
    3    
    4   Test modules frequently have the same tail name, which can result in false  
    5   positives from sys.modules caching, so the importer removes from sys.modules  
    6   any module that matches testMatch.  
      2 sys.path), and uses a per-path cache in addition to sys.modules. This is  
      3 necessary because test modules in different directories frequently have the  
      4 same names, which means that the first loaded would mask the rest when using  
      5 the builtin importer.  
    7 6 """  
    8 7 import logging  
     
    30 29          
    31 30 def _import(name, path, conf):  
    32       """Import a module *only* from path, ignoring sys.path and possibly  
      31     """Import a module *only* from path, ignoring sys.path and  
    32 31     reloading if the version in sys.modules is not the one we want.  
    33 32     """  
  • trunk/nose/proxy.py

    r26 r28  
      1 """Compatibility shim for running under the setuptools test command. The  
      2 ResultProxy wraps the actual TestResult passed to a test and implements output  
      3 capture and plugin support. TestProxy wraps test cases and in those wrapped  
      4 test cases, wraps the TestResult with a ResultProxy.  
      5  
      6 To enable this functionality, use ResultProxySuite as the suiteClass in a  
      7 TestLoader.  
      8 """  
    1 9 import unittest  
    2 10 from nose.result import Result, ln  
     
    58 66      
    59 67 class ResultProxySuite(unittest.TestSuite):  
      68     """Test suite that supports output capture, etc, by wrapping each test in  
      69     a TestProxy.  
      70     """  
    60 71     def __iter__(self):  
    61 72         return iter(map(TestProxy, self._tests))  
     
    63 74  
    64 75 class TestProxy(unittest.TestCase):  
    65    
      76     """Test case that wraps the test result in a ResultProxy.  
      77     """  
    66 78     resultProxy = ResultProxy  
    67 79      
  • trunk/nose/inspector.py

    r24 r28  
      1 """Simple traceback introspection. Used to add additional information to  
      2 AssertionErrors in tests, so that failure messages may be more informative.  
      3 """  
    1 4 import exceptions  
    2 5 import inspect  
     
    58 61     """Get source from  a traceback object.  
    59 62  
    60       A tuple of two things is returned:  a list of lines of context from  
      63     A tuple of two things is returned: a list of lines of context from  
    60 63     the source code, and the index of the current line within that list.  
    61 64     The optional second argument specifies the number of lines of context  
     
    65 68     NOTE:  
    66 69      
    67       This is taken from the python 2.4 standard library, since a bug in the 2.3  
    68       version of inspect prevents it from correctly locating source lines in a  
    69       traceback frame.  
      70     This is adapted from inspect.py in the python 2.4 standard library, since  
      71     a bug in the 2.3 version of inspect prevents it from correctly locating  
      72     source lines in a traceback frame.  
    70 73     """  
    71 74     lineno = tb.tb_lineno  
     
    85 88     else:  
    86 89         lines = index = None  
    87    
    88 90     return (lines, index)     
    89 91  
  • trunk/nose/loader.py

    r23 r28  
      1 """Discovery-based test loader.  
      2 """  
    1 3 import logging  
    2 4 import os  
     
    17 19      
    18 20 class TestLoader(unittest.TestLoader):  
    19       """Test loader.  
      21     """Default nose test loader.  
    19 21  
    20       FIXME docs  
      22     Methods that shadow those in unittest.TestLoader are compatible with the  
      23     usage in the base class. Others may be generators or interpret 'module' as  
      24     the module prefix of the thing to be loaded, not the module to be  
      25     examined, for example. Integrates closely with nose.selector.Selector to  
      26     determine what is a test, and classes in nose.suite to defer loading as  
      27     long as possible.  
    21 28     """  
    22 29     def __init__(self, conf=None, selector=None):  
     
    151 158                                                  importPath=importPath)  
    152 159         elif module:  
    153               # handle func-like names in a module  
    154                
      160             # handle func-like names in a module             
    155 161             raise ValueError("No module or file specified in test name")  
    156 162         if tests:  
     
    169 175         loadTestsFromModule() is called. Otherwise, the names are  
    170 176         loaded one by one using loadTestsFromName.  
    171           """  
    172                        
      177         """                     
    173 178         def rel(name, mod):  
    174 179             if not name.startswith(':'):  
     
    202 207     def loadTestsFromPath(self, path, module=None, importPath=None):  
    203 208         """Load tests from file or directory at path.  
    204    
    205 209         """  
    206 210         head, test = os.path.split(path)  
     
    328 332             cases.append(run)  
    329 333         return cases  
    330    
    331 334      
    332 335 defaultTestLoader = TestLoader  
  • trunk/scripts/mkrelease.py

    r27 r28  
    22 22 version = nose.__version__  
    23 23      
    24   # make docs  
    25   runcmd('%s/scripts/mkindex.py' % here)  
    26   runcmd('%s/scripts/mkwiki.py' % here)  
    27 24  
    28 25 # make branch  
    29 26 # old: runcmd('bzr branch . ../nose_dev-%s' % version)  
      27  
      28 # FIXME do this in svn work dir not here, and use svn  
      29 # then do all of the other steps from the new branch dir  
    30 30 runcmd('svk copy %s %s/../branches/%s-stable' % (here, here, version))  
    31 31  
     
    33 33 runcmd('svk copy %s %s/../tags/%s-release' % (here, here, version))  
    34 34  
      35 # make docs  
      36 runcmd('%s/scripts/mkindex.py' % here)  
      37 runcmd('%s/scripts/mkwiki.py' % here)  
      38  
    35 39 # setup sdist  
    36 40 runcmd('python setup.py sdist')  
     
    43 47                                        'upload': os.environ['NOSE_UPLOAD'] }  
    44 48     runcmd(cmd)  
    45    
    46       # FIXME push the branch & tag to master svn server  
    47 49      
    48 50     # tmp = os.getcwd()  
  • trunk/scripts/mkindex.py

    r26 r28  
    3 3 from docutils.core import publish_string, publish_parts  
    4 4 import nose  
      5 import os  
    5 6 import time  
    6 7  
      8 root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))  
      9  
    7 10 print "Main..."  
    8   tpl = open('index.html.tpl','r').read()  
    9   docs = publish_parts(nose.__doc__.replace(':: python','::'),writer_name='html')  
    10   docs.update({'version':nose.__version__,  
    11                'date':time.ctime()})  
      11 tpl = open(os.path.join(root, 'index.html.tpl'), 'r').read()  
      12 docs = publish_parts(nose.__doc__.replace(':: python','::'),  
      13                      writer_name='html')  
      14 docs.update({'version': nose.__version__,  
      15              'date': time.ctime()})  
      16  
      17 print "Tools..."  
      18 # FIXME  
    12 19  
    13 20 print "Changelog..."  
    14   changes = open('CHANGELOG','r').read()  
    15   changes_html = publish_parts(changes,writer_name='html')  
      21 changes = open(os.path.join(root, 'CHANGELOG'), 'r').read()  
      22 changes_html = publish_parts(changes, writer_name='html')  
    16 23 docs['changelog'] = changes_html['body']  
    17 24  
    18 25 print "News..."  
    19   news = open('NEWS','r').read()  
    20   news_html = publish_parts(news,writer_name='html')  
      26 news = open(os.path.join(root, 'NEWS'), 'r').read()  
      27 news_html = publish_parts(news, writer_name='html')  
    21 28 docs['news'] = news_html['body']  
    22 29  
    23 30 print "Usage..."  
    24   usage_txt = '\n'.join([ ln.replace('    ','') for ln in  
    25                           nose.TestProgram.__doc__.split('\n')]).replace('%prog',  
    26                                                                          'nosetests')  
    27    
    28   usage = publish_parts(usage_txt,writer_name='html')  
    29   docs['usage'] = usage['body']  
      31 usage_txt = nose.configure(help=True).replace('mkindex.py', 'nosetests')  
      32 # FIXME remove example plugin & html output parts  
      33 docs['usage'] = '<pre>%s</pre>' % usage_txt  
    30 34  
    31 35 out = tpl % docs  
    32 36  
    33   index = open('index.html','w')  
      37 index = open(os.path.join(root, 'index.html'), 'w')  
    33 37 index.write(out)  
    34 38 index.close()  
    35 39  
    36   readme = open('README.txt','w')  
      40 readme = open(os.path.join(root, 'README.txt'), 'w')  
    36 40 readme.write(nose.__doc__)  
    37 41 readme.close()  
  • trunk/index.html.tpl

    r4 r28  
    134 134       %(usage)s  
    135 135  
      136       <h2>Bug reports</h2>  
      137  
      138       <p>Please report bugs and make feature  
      139       requests <a href="http://nose.python-hosting.com">here</a>.</p>  
      140        
    136 141       <h2>Hack</h2>  
    137         <p><a href="mailto:jpellerin+nose@gmail.com">Patches are  
    138             welcome</a>. Revision control for nose is handled by bazaar-ng, a  
    139           new decentralized revision control system currently under  
    140           development. Read about  
    141           bazaar-ng <a href="http://bazaar-vcs.org/">here</a>.</p>  
    142    
    143         <p>To hack nose, you are best off grabbing a copy of the current  
    144           development branch; then you can publish your changes as a bzr branch,  
    145           and I (or other nose hackers) will be able to merge them into our  
    146           branches very easily.</p>  
    147    
    148         <p>Getting the dev branch is a three-step process:  
    149           <ol>  
    150             <li><a href="http://www.bazaar-ng.org/">Get bzr</a> -- version 0.6.2  
    151               is required</li>         
    152             <li>Pick a working directory and create a bzr branch there:  
    153               <pre class="literal-block">bzr init</pre>  
    154             </li>  
    155             <li>From your working dir, pull the nose branch:  
    156               <pre class="literal-block">bzr pull http://somethingaboutorange.com/mrl/projects/nose/branch</pre>  
    157             </li>  
    158           </ol>  
      142  
      143       <p><a href="http://nose.python-hosting.com/wiki/WritingPlugins">Write  
      144           plugins!</a> It's easy and fun.</p>  
      145        
      146       <p>Get the code:  
      147         <pre>svn co http://svn.nose.python-hosting.com/trunk</pre>  
    159 148       </p>  
    160 149  
    161         <p>Then hack away. When you have a proposed change that you think should  
    162           be merged into the main nose branch, publish it on a webserver somewhere  
    163           and <a href="mailto:jpellerin+nose@gmail.com">tell me about it</a>.</p>  
      150       <p><a href="mailto:jpellerin+nose@gmail.com">Patches are  
      151           welcome</a>. I'd suggest grabbing a copy  
      152           of <a href="http://svk.elixus.org/">svk</a> so that you can have  
      153           local version control and submit full patches against an up-to-date  
      154           tree easily.  
      155       </p>  
      156        
      157       <p>Thanks to the great folks at python hosting for providing the  
      158       subversion repository and trac instance.</p>  
    164 159        
    165 160       <h2><a name="changelog"></a>Changelog</h2>  
     
    171 166       <p>Current version: %(version)s <br />(%(date)s)</p>  
    172 167  
      168       <h2>Install</h2>  
      169       <p>Current version: <br /><tt>easy_install nose==%(version)s</tt></p>  
      170       <p>Unstable (trunk): <br /><tt>easy_instal nose==dev</tt></p>  
      171        
    173 172       <h2><a href="#usage">nosetests usage</a></h2>  
    174 173       <p>How to use the command-line test runner.</p>  
     
    178 177       <p>Sign up to receive email announcements  
    179 178         of new releases</p>  
      179  
      180       <h2><a href="http://nose.python-hosting.com/">Trac</a></h2>  
      181       <p>Report bugs, request features, wik the wiki, browse source.</p>  
      182  
      183       <h2>Get the code</h2>  
      184       <p><tt>svn co http://svn.nose.python-hosting.com/trunk</tt></p>       
    180 185        
    181 186       <h2>Other links</h2>  
  • trunk/README.txt

    r27 r28  
    248 248 ------------------  
    249 249  
    250   To report bugs, ask questions, or request features, please email the author at  
      250 To report bugs, ask questions, or request features, please use the trac  
      251 instance provided by the great folks at python hosting, here:  
      252 http://nose.python-hosting.org. Or, email the author at  
    251 253 jpellerin+nose at gmail dot com. Patches are welcome!  
    252 254