Changeset 8

Show
Ignore:
Timestamp:
02/10/06 12:44:08 (3 years ago)
Author:
grig
Message:

Refactored CodeParser? functionality. Use model.py from Michael Hudson's docextractor package.

Added configuration file. The first time cheesecake_index is run, it will create a directory
called ~/.cheesecake and a file called ~/.cheesecake/my_config.py containing default values
for various variables used throughout the index computation.

Added more unit tests.

Files:

Legend:

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

    r7 r8  
    2323from urllib import urlretrieve 
    2424from urlparse import urlparse 
    25 from subprocess import call, Popen, PIPE, STDOUT 
    26 from inspect import isclass, ismethod, isfunction 
    2725from math import ceil 
     26 
     27from _util import run_cmd, pad_with_dots, pad_left_spaces, pad_msg, pad_line 
     28from _util import StdoutRedirector 
    2829import logger 
    29  
    30 INDEX_PYPI_DOWNLOAD = 50 
    31 INDEX_PYPI_DISTANCE = 5 
    32 INDEX_URL_DOWNLOAD  = 25 
    33 INDEX_UNPACK        = 25 
    34 INDEX_UNPACK_DIR    = 15 
    35 INDEX_INSTALL       = 50 
    36 INDEX_FILE_CRITICAL = 15 
    37 INDEX_FILE          = 10 
    38 INDEX_REQUIRED_FILES = 100 
    39 INDEX_FILE_PYC      = -20 
    40 INDEX_DIR_CRITICAL  = 25 
    41 INDEX_DIR           = 20 
    42 INDEX_DIR_EMPTY     = 5 
    43  
    44 MAX_INDEX_DOCSTRINGS = 100 # max. percentage of modules/classes/methods/functions with docstrings 
    45 MAX_INDEX_PYLINT     = 100 # max. pylint score 
    46  
    47 PAD_TEXT = 40 
    48 PAD_VALUE = 4 
     30import config 
     31from codeparser import CodeParser 
    4932 
    5033class Index(object): 
     
    158141        self.sandbox_install_dir = "" 
    159142 
     143        self.set_defaults() 
     144        self.get_config_values() 
    160145        self.determine_pkg_name() 
    161146        self.configure_logging() 
     
    191176            self.log("Removing directory %s" % self.sandbox_install_dir) 
    192177            shutil.rmtree(self.sandbox_install_dir) 
     178 
     179    def set_defaults(self): 
     180        """ 
     181        Set default values for variables that can also be defined 
     182        in the config file 
     183        """ 
     184        self.INDEX_PYPI_DOWNLOAD = 50 
     185        self.INDEX_PYPI_DISTANCE = 5 
     186        self.INDEX_URL_DOWNLOAD  = 25 
     187        self.INDEX_UNPACK        = 25 
     188        self.INDEX_UNPACK_DIR    = 15 
     189        self.INDEX_INSTALL       = 50 
     190        self.INDEX_FILE_CRITICAL = 15 
     191        self.INDEX_FILE          = 10 
     192        self.INDEX_REQUIRED_FILES = 100 
     193        self.INDEX_FILE_PYC      = -20 
     194        self.INDEX_DIR_CRITICAL  = 25 
     195        self.INDEX_DIR           = 20 
     196        self.INDEX_DIR_EMPTY     = 5 
     197        self.MAX_INDEX_DOCSTRINGS = 100 # max. percentage of modules/classes/methods/functions with docstrings 
     198        self.MAX_INDEX_PYLINT     = 100 # max. pylint score 
     199        self.cheese_files = ["readme", "install", "changelog", 
     200                            "news", "faq", 
     201                            "todo", "thanks", 
     202                            "license", "announce", 
     203                            "setup.py", 
     204                            ] 
     205        self.critical_cheese_files = ["readme", "license", "setup.py"] 
     206        self.cheese_dirs = ["doc", "test", "example", "demo"] 
     207        self.critical_cheese_dirs = ["doc", "test"] 
     208 
     209    def get_config_values(self): 
     210        """ 
     211        Retrieve values from configuration file 
     212        """ 
     213        for config_var in ["INDEX_PYPI_DOWNLOAD", "INDEX_PYPI_DISTANCE", 
     214            "INDEX_URL_DOWNLOAD", "INDEX_UNPACK", "INDEX_UNPACK_DIR", 
     215            "INDEX_INSTALL", "INDEX_FILE_CRITICAL", "INDEX_FILE", 
     216            "INDEX_REQUIRED_FILES", "INDEX_FILE_PYC", 
     217            "INDEX_DIR_CRITICAL", "INDEX_DIR", "INDEX_DIR_EMPTY", 
     218            "MAX_INDEX_DOCSTRINGS", "MAX_INDEX_PYLINT", 
     219            "cheese_files", "critical_cheese_files",  
     220            "cheese_dirs", "critical_cheese_dirs", 
     221            ]: 
     222            value = config.get(config_var) 
     223            if value: setattr(self, config_var, value) 
    193224 
    194225    def determine_pkg_name(self): 
     
    227258        self.log.error = logger.MultipleProducer('cheesecake console') 
    228259 
     260        self.log.debug("package = ", self.package) 
     261 
    229262    def init_indexes(self): 
    230263        """ 
     
    238271        self.cheesecake_index_documentation = 0 
    239272        self.cheesecake_index_codekwalitee = 0 
    240         self.max_cheesecake_index = INDEX_PYPI_DOWNLOAD + \ 
    241                                     INDEX_UNPACK + \ 
    242                                     INDEX_UNPACK_DIR + \ 
    243                                     INDEX_INSTALL + \ 
    244                                     MAX_INDEX_DOCSTRINGS + \ 
    245                                     MAX_INDEX_PYLINT 
    246         self.max_cheesecake_index_installability = INDEX_PYPI_DOWNLOAD + \ 
    247                                             INDEX_UNPACK + \ 
    248                                             INDEX_UNPACK_DIR + \ 
    249                                             INDEX_INSTALL 
    250         self.max_cheesecake_index_documentation = INDEX_REQUIRED_FILES + \ 
    251                                         MAX_INDEX_DOCSTRINGS 
    252         self.max_cheesecake_index_codekwalitee = MAX_INDEX_PYLINT 
     273        self.max_cheesecake_index = self.INDEX_PYPI_DOWNLOAD + \ 
     274                                    self.INDEX_UNPACK + \ 
     275                                    self.INDEX_UNPACK_DIR + \ 
     276                                    self.INDEX_INSTALL + \ 
     277                                    self.MAX_INDEX_DOCSTRINGS + \ 
     278                                    self.MAX_INDEX_PYLINT 
     279        self.max_cheesecake_index_installability = self.INDEX_PYPI_DOWNLOAD + \ 
     280                                            self.INDEX_UNPACK + \ 
     281                                            self.INDEX_UNPACK_DIR + \ 
     282                                            self.INDEX_INSTALL 
     283        self.max_cheesecake_index_documentation = self.INDEX_REQUIRED_FILES + \ 
     284                                        self.MAX_INDEX_DOCSTRINGS 
     285        self.max_cheesecake_index_codekwalitee = self.MAX_INDEX_PYLINT 
    253286        self.index = {} 
    254287        for index_type in ["file", "dir"]: 
     
    259292            self.index[index_type] = Index(index_type) 
    260293 
    261         self.cheese_files = ["readme", "install", "changelog", 
    262                             "news", "faq", 
    263                             "todo", "thanks", 
    264                             "license", "announce",  
    265                             "setup.py", "ez_setup.py", 
    266                             ] 
    267         self.critical_cheese_files = ["readme", "license", "setup.py"] 
    268294        for cheese_file in self.cheese_files: 
    269295            self.index["file"].set_index(name=cheese_file, details="file not found") 
    270296            if cheese_file in self.critical_cheese_files: 
    271                 self.max_cheesecake_index += INDEX_FILE_CRITICAL 
    272                 self.max_cheesecake_index_documentation += INDEX_FILE_CRITICAL 
     297                self.max_cheesecake_index += self.INDEX_FILE_CRITICAL 
     298                self.max_cheesecake_index_documentation += self.INDEX_FILE_CRITICAL 
    273299            else: 
    274                 self.max_cheesecake_index += INDEX_FILE 
    275                 self.max_cheesecake_index_documentation += INDEX_FILE 
     300                self.max_cheesecake_index += self.INDEX_FILE 
     301                self.max_cheesecake_index_documentation += self.INDEX_FILE 
    276302        self.log.debug("cheese_files: " + ",".join(self.cheese_files)) 
    277303        self.log.debug("critical_cheese_files: " + ",".join(self.critical_cheese_files)) 
    278304 
    279         self.cheese_dirs = ["doc", "test", "example", "demo"] 
    280         self.critical_cheese_dirs = ["doc", "test"] 
    281305        for cheese_dir in self.cheese_dirs: 
    282306            self.index["dir"].set_index(name=cheese_dir, details="directory not found") 
    283307            if cheese_dir in self.critical_cheese_dirs: 
    284                 self.max_cheesecake_index += INDEX_DIR_CRITICAL 
    285                 self.max_cheesecake_index_documentation += INDEX_DIR_CRITICAL 
     308                self.max_cheesecake_index += self.INDEX_DIR_CRITICAL 
     309                self.max_cheesecake_index_documentation += self.INDEX_DIR_CRITICAL 
    286310            else: 
    287                 self.max_cheesecake_index += INDEX_DIR 
    288                 self.max_cheesecake_index_documentation += INDEX_DIR 
     311                self.max_cheesecake_index += self.INDEX_DIR 
     312                self.max_cheesecake_index_documentation += self.INDEX_DIR 
    289313        self.log.debug("cheese_dirs: " + ",".join(self.cheese_dirs)) 
    290314        self.log.debug("critical_cheese_dirs: " + ",".join(self.critical_cheese_dirs)) 
     
    363387            found_on_cheeseshop = False 
    364388            if re.search(r"cheeseshop.python.org", download_url): 
    365                 value = INDEX_PYPI_DOWNLOAD 
     389                value = self.INDEX_PYPI_DOWNLOAD 
    366390                found_on_cheeseshop = True 
    367391            else: 
    368                 value = INDEX_PYPI_DOWNLOAD - distance_from_pypi * INDEX_PYPI_DISTANCE 
     392                value = self.INDEX_PYPI_DOWNLOAD - distance_from_pypi * self.INDEX_PYPI_DISTANCE 
    369393            self.index[index_type].value = value 
    370394            details = "downloaded package " + self.package 
     
    404428            f.close() 
    405429        index_type = "url_download" 
    406         self.index[index_type].value = INDEX_URL_DOWNLOAD 
     430        self.index[index_type].value = self.INDEX_URL_DOWNLOAD 
    407431        self.index[index_type].details = "downloaded package %s from URL %s"  % (self.package, self.url) 
    408432         
     
    457481        else: 
    458482            details += " as expected" 
    459             self.index[index_type].value = INDEX_UNPACK_DIR 
     483            self.index[index_type].value = self.INDEX_UNPACK_DIR 
    460484        self.index[index_type].details = details 
    461485 
     
    481505 
    482506        index_type = "unpack" 
    483         self.index[index_type].value = INDEX_UNPACK 
     507        self.index[index_type].value = self.INDEX_UNPACK 
    484508        self.index[index_type].details = "package untar-ed successfully" 
    485509             
     
    514538 
    515539        index_type = "unpack" 
    516         self.index[index_type].value = INDEX_UNPACK 
     540        self.index[index_type].value = self.INDEX_UNPACK 
    517541        self.index[index_type].details = "package unzipped successfully" 
    518542 
     
    533557                    if files or dirs: 
    534558                        if cheese_dir in self.critical_cheese_dirs: 
    535                             value = INDEX_DIR_CRITICAL 
     559                            value = self.INDEX_DIR_CRITICAL 
    536560                            details = "critical directory found" 
    537561                            self.log.debug("critical_cheese_dir found: " + cheese_dir) 
    538562                        else: 
    539                             value = INDEX_DIR 
     563                            value = self.INDEX_DIR 
    540564                            details = "directory found" 
    541565                            self.log.debug("cheese_dir found: " + cheese_dir) 
    542566                    else: 
    543                         value = INDEX_DIR_EMPTY 
     567                        value = self.INDEX_DIR_EMPTY 
    544568                        details = "empty directory found" 
    545569                        self.log.debug("empty cheese_dir found: " + cheese_dir) 
     
    550574                    if re.search(r"^%s(\.txt)*" % cheese_file, file, re.IGNORECASE): 
    551575                        if cheese_file in self.critical_cheese_files: 
    552                             value = INDEX_FILE_CRITICAL 
     576                            value = self.INDEX_FILE_CRITICAL 
    553577                            details = "critical file found" 
    554578                            self.log.debug("critical_cheese_file found: " + cheese_file) 
    555579                        else: 
    556                             value = INDEX_FILE 
     580                            value = self.INDEX_FILE 
    557581                            details = "file found" 
    558582                            self.log.debug("cheese_file found: " + cheese_file) 
     
    570594        len_pyc_list = len(self.pkg_files["pyc"]) 
    571595        if len_pyc_list: 
    572             self.index["file"].set_index("pyc", value=-INDEX_FILE_PYC, 
     596            self.index["file"].set_index("pyc", value=self.INDEX_FILE_PYC, 
    573597                details="%d .pyc files found" % len_pyc_list) 
    574598        self.log.debug("Found %d py files" % len(self.pkg_files["py"])) 
     
    676700        cwd = os.getcwd() 
    677701        os.chdir(os.path.join(self.sandbox, self.package_name)) 
    678         p = Popen(["python", "setup.py",  "install", "--home=%s" % self.sandbox_install_dir], stdout=PIPE, stderr=STDOUT) 
    679         output = p.communicate()[0] 
    680         if not p.returncode: 
     702        rc, output = run_cmd("python setup.py install --home=" + self.sandbox_install_dir) 
     703        if not rc: 
    681704            # Install succeeded 
    682             self.index[index_type].value = INDEX_INSTALL 
     705            self.index[index_type].value = self.INDEX_INSTALL 
    683706            self.index[index_type].details = details="package installed in %s" % self.sandbox_install_dir 
    684707        else: 
     
    722745        index_type = "pylint" 
    723746            # Try to run the pylint script 
    724         p = Popen(["pylint", "--version"], stdout=PIPE, stderr=STDOUT) 
    725         output = p.communicate()[0] 
    726         rc = p.returncode 
     747        rc, output = run_cmd("pylint --version") 
    727748        if rc: 
    728749            # We encountered an error 
     
    738759            fullpath = os.path.join(self.sandbox, pyfile) 
    739760            self.log.debug("Running pylint on file " + fullpath) 
    740             p = Popen(["pylint", fullpath], stdout=PIPE, stderr=STDOUT) 
    741             output = p.communicate()[0] 
    742             rc = p.returncode 
     761            rc, output = run_cmd("pylint " + fullpath) 
    743762            if rc: 
    744763                # We encountered an error 
     
    755774                index_pylint += float(score) 
    756775                cnt += 1 
    757         avg_value = float(index_pylint)/float(cnt) 
     776        if cnt: 
     777            avg_value = float(index_pylint)/float(cnt) 
     778        else: 
     779            avg_value = 0 
    758780        index_value = int(ceil(avg_value*10)) 
    759781        self.index[index_type].value = index_value 
     
    788810 
    789811        print 
    790         self.print_line("=" * (PAD_TEXT + PAD_VALUE + 1)
     812        self.print_separator_line(
    791813        print pad_msg("OVERALL CHEESECAKE INDEX (ABSOLUTE)", self.cheesecake_index) 
    792814        percentage = (self.cheesecake_index * 100) / self.max_cheesecake_index 
     
    807829            partial_index_value += self.process_index(index_type) 
    808830 
    809         self.print_line("-" * (PAD_TEXT + PAD_VALUE + 1)
     831        self.print_separator_line("-"
    810832        print pad_msg("%s INDEX (ABSOLUTE)" % partial_index_name, partial_index_value) 
    811833        percentage = (partial_index_value * 100) / max_value 
     
    828850        return index.value 
    829851 
    830     def print_line(self, line): 
     852    def print_separator_line(self, char=""): 
    831853        """ 
    832854        Print line of text, unless quiet flag was given 
     
    834856        if self.quiet: 
    835857            return 
    836         print line 
    837  
    838  
    839 class CodeParser(object): 
    840     """ 
    841     Information about the structure of a Python module 
    842  
    843     * Collects classes, methods, functions and any associated docstrings 
    844     * Does some dumb grep-style parsing, but in the future may do some real smart parsing 
    845     """ 
    846     def __init__(self, pyfile, log=None): 
    847         if log: 
    848             self.log = log.codeparser 
    849         else: 
    850             self.log = logger.default.codeparser 
    851         self.classes = [] 
    852         self.methods = [] 
    853         self.functions = [] 
    854         self.docstrings = {} 
    855         self.object_at_page = {} 
    856         try: 
    857             self.fh = open(pyfile) 
    858         except IOError, e: 
    859             print str(e) 
    860             return 
    861          
    862         (path, filename) = os.path.split(pyfile) 
    863         (self.module, ext) = os.path.splitext(filename) 
    864         self.log("Inspecting file: " + pyfile) 
    865  
    866         self.parse_file() 
    867         self.log("classes: " + ",".join(self.classes)) 
    868         self.log("methods: " + ",".join(self.methods)) 
    869         self.log("functions: " + ",".join(self.functions)) 
    870  
    871     def parse_file(self): 
    872         """ 
    873         Parse module text and retrieve classes, methods, functions 
    874         and associated docstrings 
    875         """ 
    876         cls_found = method_found = func_found = 0 
    877         cls = method = func = "" 
    878         crt_line = 0 
    879         for line in self.fh: 
    880             crt_line += 1 
    881             if not self.object_at_page.has_key(crt_line-1): 
    882                 s = re.search(r"\"\"\"", line) 
    883                 if s: 
    884                     self.docstrings[self.module] = 1 
    885             s = re.search(r"^class (\S+)(\(|:)", line) 
    886             if s: 
    887                 cls = s.group(1) 
    888                 self.classes.append(cls) 
    889                 self.object_at_page[crt_line] = cls 
    890                 self.log("Found class " + cls) 
    891                 continue 
    892             s = re.search(r"^\s+def (\S+)\(", line) 
    893             if s: 
    894                 method = s.group(1) 
    895                 if method.startswith("__"): 
    896                     self.log("Skipping method " + method) 
    897                     continue 
    898                 self.methods.append(method) 
    899                 self.object_at_page[crt_line] = method 
    900                 self.log("Found method " + method) 
    901                 continue 
    902             s = re.search(r"^def (\S+)\(", line) 
    903             if s: 
    904                 func = s.group(1) 
    905                 self.functions.append(func) 
    906                 self.object_at_page[crt_line] = func 
    907                 self.log("Found function " + func) 
    908                 continue 
    909             s1 = re.search(r"\"\"\"", line) 
    910             s2 = re.search(r"\".*\S+.*\"", line) 
    911             if s1 or s2: 
    912                 # LOok at object if any on previous line 
    913                 obj1 = self.object_at_page.get(crt_line-1) 
    914                 obj2 = None 
    915                 if crt_line > 1: 
    916                     # Look at object is any 2 lines before 
    917                     obj2 = self.object_at_page.get(crt_line-2) 
    918                 obj = obj1 or obj2 
    919                 if obj: 
    920                     self.docstrings[obj] = 1 
    921                     self.log("Found docstring for object " + obj) 
    922                  
    923     def object_count(self): 
    924         """ 
    925         Return number of objects found in this module 
    926  
    927         * module 
    928         * classes 
    929         * methods 
    930         * functions 
    931         """ 
    932         module_count = 1 
    933         cls_count = len(self.classes) 
    934         method_count = len(self.methods) 
    935         func_count = len(self.functions) 
    936         return module_count + cls_count + method_count + func_count 
    937  
    938     def docstring_count(self): 
    939         """ 
    940         Return number of docstrings found in this module 
    941         """ 
    942         return len(self.docstrings.keys()) 
    943  
    944 class StdoutRedirector(object): 
    945     """ 
    946     Redirect stdout to a temp file 
    947     """ 
    948  
    949     def __init__(self, filename=None): 
    950         if filename: 
    951             self.fh = open(filename, 'w') 
    952         else: 
    953             self.fh = os.tmpfile() 
    954  
    955     def write(self, buf): 
    956         self.fh.write(buf) 
    957  
    958     def flush(self): 
    959         self.fh.flush() 
    960  
    961     def read_buffer(self): 
    962         """ 
    963         Return contents of the temp file 
    964         """ 
    965         self.fh.seek(0) 
    966         return self.fh.read() 
    967  
    968 ### Utility functions ### 
    969  
    970 def pad_with_dots(msg, length=PAD_TEXT): 
    971     """ 
    972     Pad text with dots up to given length 
    973     """ 
    974     length = len(msg) 
    975     msg = msg + " " 
    976     for i in range(length, PAD_TEXT): 
    977         msg += "." 
    978     return msg 
    979  
    980 def pad_left_spaces(value, length=PAD_VALUE): 
    981     """ 
    982     Pad value with spaces at left up to given length 
    983     """ 
    984     msg = "" 
    985     diff = length - len(str(value)) 
    986     for i in range(diff): 
    987         msg += " " 
    988     msg += str(value) 
    989     return msg 
    990  
    991 def pad_msg(msg, value): 
    992     """ 
    993     Pad message with dots and pad value with spaces 
    994     """ 
    995     length = len(msg) 
    996     msg = msg + " " 
    997     for i in range(length, PAD_TEXT): 
    998         msg += "." 
    999     diff = PAD_VALUE - len(str(value)) 
    1000     for i in range(diff): 
    1001         msg += " " 
    1002     msg += str(value) 
    1003     return msg 
    1004  
    1005 ### End utility functions ### 
     858        print pad_line(char) 
     859 
    1006860 
    1007861def process_cmdline_args(): 
  • trunk/tests/data/module1.py

    r2 r8  
    1010    def __init__(self): 
    1111        """ 
    12         Methods starting with __ should be skipped 
     12        Methods starting with __ are not kipped 
    1313        """ 
    1414        pass 
    1515 
    1616    def __another_method__(self): 
    17         """Should also be skipped""" 
     17        """Should not be skipped""" 
    1818        pass 
    1919 
  • trunk/tests/test_code_parser.py

    r2 r8  
    11import _path_cheesecake 
    2 from cheesecake.cheesecake_index import CodeParser 
     2from cheesecake.codeparser import CodeParser 
    33import os 
    44datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) 
     
    88        self.code1 = CodeParser(os.path.join(datadir, "module1.py")) 
    99 
     10    def test_modules(self): 
     11        assert self.code1.modules == ["module1"] 
     12 
    1013    def test_classes(self): 
    11         assert self.code1.classes == ["Class1", "Class2"] 
    12  
    13     def test_methods(self): 
    14         assert self.code1.methods == ["method1", "method2", "method3", "method4"] 
     14        assert self.code1.classes == ["module1.Class1", "module1.Class2"] 
    1515 
    1616    def test_functions(self): 
    17         assert self.code1.functions == ["func1", "func2", "func3", "func4", "__func5__"] 
    18  
     17        assert self.code1.functions == ["module1.Class1.__init__", "module1.Class1.__another_method__",\ 
     18                            "module1.Class1.method1", "module1.Class1.method2", "module1.Class1.method3", \ 
     19                            "module1.Class1.method4", "module1.func1", "module1.func2", "module1.func3", \ 
     20                            "module1.func4", "module1.__func5__"] 
    1921    def test_count(self): 
    20         assert self.code1.object_count() == 12 
    21         assert self.code1.docstring_count() == 10 
     22        assert self.code1.object_count() == 14 
     23        assert self.code1.docstring_count() == 12 
    2224 
    2325    def test_docstrings(self): 
     26        print self.code1.docstrings 
    2427        assert self.code1.docstrings.get("module1") == 1 
    25         for object in ["Class1", "Class2"]: 
     28        for object in ["module1.Class1", "module1.Class2"]: 
    2629            assert self.code1.docstrings.get(object) == 1 
    27         for object in ["method1", "method2", "method3"]: 
     30        for object in ["module1.Class1.__init__", "module1.Class1.__another_method__",\ 
     31                    "module1.Class1.method1", "module1.Class1.method2", "module1.Class1.method3"]: 
    2832            assert self.code1.docstrings.get(object) == 1 
    29         assert not self.code1.docstrings.get("method4") 
    30         for object in ["func1", "func2", "func3", "__func5__"]: 
     33        assert not self.code1.docstrings.get("module1.Class1.method4") 
     34        for object in ["module1.func1", "module1.func2", "module1.func3", "module1.__func5__"]: 
    3135            assert self.code1.docstrings.get(object) == 1 
    32         assert not self.code1.docstrings.get("func4") 
     36        assert not self.code1.docstrings.get("module1.func4") 
  • trunk/tests/test_index_install.py

    r2 r8  
    11import _path_cheesecake 
    2 from cheesecake.cheesecake_index import Cheesecake, INDEX_INSTALL 
     2from cheesecake.cheesecake_index import Cheesecake 
    33import os 
    44datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) 
     
    1919        index = self.cheesecake.index_install() 
    2020        assert index.name == "index_install" 
    21         assert index.value == INDEX_INSTALL 
     21        assert index.value == self.cheesecake.INDEX_INSTALL 
    2222        assert index.details == "package installed in " + self.cheesecake.sandbox_install_dir 
    2323 
  • trunk/tests/test_index_installability.py

    r2 r8  
    11import _path_cheesecake 
    2 from cheesecake.cheesecake_index import Cheesecake, INDEX_PYPI_DOWNLOAD,\ 
    3         INDEX_URL_DOWNLOAD, INDEX_UNPACK, INDEX_UNPACK_DIR, INDEX_INSTALL 
     2from cheesecake.cheesecake_index import Cheesecake 
    43import os 
    54datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) 
     
    1817    def test_index_installability_local_path(self): 
    1918        self.cheesecake = Cheesecake(path=os.path.join(datadir, "nose-0.8.3.tar.gz")) 
    20         assert self.cheesecake.max_cheesecake_index_installability == INDEX_PYPI_DOWNLOAD + \ 
    21                                     INDEX_UNPACK + INDEX_UNPACK_DIR + INDEX_INSTALL 
     19        assert self.cheesecake.max_cheesecake_index_installability == \ 
     20            self.cheesecake.INDEX_PYPI_DOWNLOAD + self.cheesecake.INDEX_UNPACK + \ 
     21            self.cheesecake.INDEX_UNPACK_DIR + self.cheesecake.INDEX_INSTALL 
     22                                     
    2223        index_types = ["pypi_download", "unpack", "unpack_dir", "install"] 
    2324        cheesecake_index_installability = self.cheesecake.process_partial_index("INSTALLABILITY",\ 
    2425                                         index_types, self.cheesecake.max_cheesecake_index_installability) 
    25         assert cheesecake_index_installability == INDEX_UNPACK + INDEX_UNPACK_DIR + INDEX_INSTALL 
     26        assert cheesecake_index_installability == self.cheesecake.INDEX_UNPACK + \ 
     27                self.cheesecake.INDEX_UNPACK_DIR + self.cheesecake.INDEX_INSTALL 
    2628 
    2729    def test_index_installability_url_download(self): 
    2830        self.cheesecake = Cheesecake(url="http://www.agilistas.org/cheesecake/nose-0.8.3.tar.gz") 
    29         assert self.cheesecake.max_cheesecake_index_installability == INDEX_PYPI_DOWNLOAD + \ 
    30                                     INDEX_UNPACK + INDEX_UNPACK_DIR + INDEX_INSTALL 
     31        assert self.cheesecake.max_cheesecake_index_installability == \ 
     32            self.cheesecake.INDEX_PYPI_DOWNLOAD + self.cheesecake.INDEX_UNPACK + \ 
     33            self.cheesecake.INDEX_UNPACK_DIR + self.cheesecake.INDEX_INSTALL 
    3134        index_types = ["pypi_download", "url_download", "unpack", "unpack_dir", "install"] 
    3235        cheesecake_index_installability = self.cheesecake.process_partial_index("INSTALLABILITY",\ 
    3336                                         index_types, self.cheesecake.max_cheesecake_index_installability) 
    34         assert cheesecake_index_installability == INDEX_URL_DOWNLOAD + INDEX_UNPACK + INDEX_UNPACK_DIR + INDEX_INSTALL 
    35  
    36  
     37        assert cheesecake_index_installability == \ 
     38            self.cheesecake.INDEX_URL_DOWNLOAD + self.cheesecake.INDEX_UNPACK + \ 
     39            self.cheesecake.INDEX_UNPACK_DIR + self.cheesecake.INDEX_INSTALL 
  • trunk/tests/test_index_unpack.py

    r2 r8  
    11import _path_cheesecake 
    2 from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, INDEX_UNPACK, pad_msg 
     2from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, pad_msg 
    33import os 
    44datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) 
     
    1919        index = self.cheesecake.index_unpack() 
    2020        assert index.name == "index_unpack" 
    21         assert index.value == INDEX_UNPACK 
     21        assert index.value == self.cheesecake.INDEX_UNPACK 
    2222        assert index.details == "package untar-ed successfully" 
    2323 
     
    2626        index = self.cheesecake.index_unpack() 
    2727        assert index.name == "index_unpack" 
    28         assert index.value == INDEX_UNPACK 
     28        assert index.value == self.cheesecake.INDEX_UNPACK 
    2929        assert index.details == "package untar-ed successfully" 
    3030 
     
    3333        index = self.cheesecake.index_unpack() 
    3434        assert index.name == "index_unpack" 
    35         assert index.value == INDEX_UNPACK 
     35        assert index.value == self.cheesecake.INDEX_UNPACK 
    3636        assert index.details == "package unzipped successfully" 
    3737 
  • trunk/tests/test_index_unpack_dir.py

    r2 r8  
    11import _path_cheesecake 
    2 from cheesecake.cheesecake_index import Cheesecake, INDEX_UNPACK_DIR 
     2from cheesecake.cheesecake_index import Cheesecake 
    33import os 
    44datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) 
     
    1919        index = self.cheesecake.index_unpack_dir() 
    2020        assert index.name == "index_unpack_dir" 
    21         assert index.value == INDEX_UNPACK_DIR 
     21        assert index.value == self.cheesecake.INDEX_UNPACK_DIR 
    2222        assert index.details == "unpack directory is " + self.cheesecake.package_name + " as expected" 
    2323 
  • trunk/tests/test_index_url_download.py

    r2 r8  
    11import _path_cheesecake 
    2 from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, INDEX_URL_DOWNLOAD, pad_msg 
     2from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, pad_msg 
    33         
    44import os 
     
    2121            index = self.cheesecake.index_url_download() 
    2222            assert index.name == "index_url_download" 
    23             assert index.value == INDEX_URL_DOWNLOAD 
     23            assert index.value == self.cheesecake.INDEX_URL_DOWNLOAD 
    2424            assert index.details == "downloaded package " + self.cheesecake.package + " from URL " + self.cheesecake.url 
    2525        except CheesecakeError, e: