Changeset 98 for branches

Show
Ignore:
Timestamp:
07/21/06 10:04:44 (7 years ago)
Author:
mk
Message:

Added missing unit tests for command_successful, run_cmd and Index.repr.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/mk/cheesecake/cheesecake_index.py

    r97 r98  
    106106    >>> discover_file_type('examples/runthis.py') 
    107107    'demo' 
     108    >>> discover_file_type('optimized.pyo') 
     109    'pyo' 
    108110 
    109111    >>> test_files = ['ut/test_this_and_that.py', 
     
    467469        msg = pad_msg("%s INDEX (RELATIVE)" % self.name, percentage) 
    468470        msg += "  (%d out of a maximum of %d points is %d%%)" %\ 
    469              (self.value, max_value, percentage) 
     471               (self.value, max_value, percentage) 
    470472 
    471473        print msg 
  • branches/mk/cheesecake/codeparser.py

    r89 r98  
    33import re 
    44 
     5import logger 
    56from model import System, Module, Class, Function, parseFile, processModuleAst 
    67 
     
    112113            self.log = log.codeparser 
    113114        else: 
    114             import logger 
    115115            self.log = logger.default.codeparser 
    116116        self.modules = [] 
  • branches/mk/cheesecake/util.py

    r78 r98  
    1212def run_cmd(cmd, env=None): 
    1313    """Run command and return its return code and its output. 
     14 
     15    >>> run_cmd('/bin/true') 
     16    (0, '') 
    1417    """ 
    1518    arglist = cmd.split() 
     
    2326def command_successful(cmd): 
    2427    """Returns True if command exited normally, False otherwise. 
     28 
     29    >>> command_successful('/bin/true') 
     30    True 
     31    >>> command_successful('this-command-doesnt-exist') 
     32    False 
    2533    """ 
    2634    rc, output = run_cmd(cmd) 
     
    3038 
    3139class StdoutRedirector(object): 
     40    """Redirect stdout to a temporary file. 
    3241    """ 
    33     Redirect stdout to a temp file 
    34     """ 
    35  
    3642    def __init__(self, filename=None): 
    3743        if filename: 
     
    4753 
    4854    def read_buffer(self): 
    49         """ 
    50         Return contents of the temp file 
     55        """Return contents of the temporary file. 
    5156        """ 
    5257        self.fh.seek(0) 
     
    5459 
    5560def pad_with_dots(msg, length=PAD_TEXT): 
    56     """ 
    57     Pad text with dots up to given length 
     61    """Pad text with dots up to given length. 
    5862    """ 
    5963    length = len(msg) 
  • branches/mk/tests/unit/test_index_class.py

    r92 r98  
    1010    >>> index.max_value 
    1111    0 
     12 
     13To learn a class name, ask for its representation. 
     14    >>> Index 
     15    <Index class: unnamed> 
     16    >>> class NamedIndex(Index): 
     17    ...     pass 
     18    >>> NamedIndex 
     19    <Index class: NamedIndex> 
    1220 
    1321*****