- Timestamp:
- 02/10/06 12:44:08 (7 years ago)
- Files:
-
- trunk/cheesecake/_util.py (added)
- trunk/cheesecake/cheesecake_index.py (modified) (22 diffs)
- trunk/cheesecake/codeparser.py (added)
- trunk/cheesecake/model.py (added)
- trunk/tests/data/module1.py (modified) (1 diff)
- trunk/tests/test_code_parser.py (modified) (2 diffs)
- trunk/tests/test_config.py (added)
- trunk/tests/test_index_install.py (modified) (2 diffs)
- trunk/tests/test_index_installability.py (modified) (2 diffs)
- trunk/tests/test_index_unpack.py (modified) (4 diffs)
- trunk/tests/test_index_unpack_dir.py (modified) (2 diffs)
- trunk/tests/test_index_url_download.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cheesecake/cheesecake_index.py
r7 r8 23 23 from urllib import urlretrieve 24 24 from urlparse import urlparse 25 from subprocess import call, Popen, PIPE, STDOUT26 from inspect import isclass, ismethod, isfunction27 25 from math import ceil 26 27 from _util import run_cmd, pad_with_dots, pad_left_spaces, pad_msg, pad_line 28 from _util import StdoutRedirector 28 29 import 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 30 import config 31 from codeparser import CodeParser 49 32 50 33 class Index(object): … … 158 141 self.sandbox_install_dir = "" 159 142 143 self.set_defaults() 144 self.get_config_values() 160 145 self.determine_pkg_name() 161 146 self.configure_logging() … … 191 176 self.log("Removing directory %s" % self.sandbox_install_dir) 192 177 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) 193 224 194 225 def determine_pkg_name(self): … … 227 258 self.log.error = logger.MultipleProducer('cheesecake console') 228 259 260 self.log.debug("package = ", self.package) 261 229 262 def init_indexes(self): 230 263 """ … … 238 271 self.cheesecake_index_documentation = 0 239 272 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_PYLINT246 self.max_cheesecake_index_installability = INDEX_PYPI_DOWNLOAD + \247 INDEX_UNPACK + \248 INDEX_UNPACK_DIR + \249 INDEX_INSTALL250 self.max_cheesecake_index_documentation = INDEX_REQUIRED_FILES + \251 MAX_INDEX_DOCSTRINGS252 self.max_cheesecake_index_codekwalitee = MAX_INDEX_PYLINT273 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 253 286 self.index = {} 254 287 for index_type in ["file", "dir"]: … … 259 292 self.index[index_type] = Index(index_type) 260 293 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"]268 294 for cheese_file in self.cheese_files: 269 295 self.index["file"].set_index(name=cheese_file, details="file not found") 270 296 if cheese_file in self.critical_cheese_files: 271 self.max_cheesecake_index += INDEX_FILE_CRITICAL272 self.max_cheesecake_index_documentation += INDEX_FILE_CRITICAL297 self.max_cheesecake_index += self.INDEX_FILE_CRITICAL 298 self.max_cheesecake_index_documentation += self.INDEX_FILE_CRITICAL 273 299 else: 274 self.max_cheesecake_index += INDEX_FILE275 self.max_cheesecake_index_documentation += INDEX_FILE300 self.max_cheesecake_index += self.INDEX_FILE 301 self.max_cheesecake_index_documentation += self.INDEX_FILE 276 302 self.log.debug("cheese_files: " + ",".join(self.cheese_files)) 277 303 self.log.debug("critical_cheese_files: " + ",".join(self.critical_cheese_files)) 278 304 279 self.cheese_dirs = ["doc", "test", "example", "demo"]280 self.critical_cheese_dirs = ["doc", "test"]281 305 for cheese_dir in self.cheese_dirs: 282 306 self.index["dir"].set_index(name=cheese_dir, details="directory not found") 283 307 if cheese_dir in self.critical_cheese_dirs: 284 self.max_cheesecake_index += INDEX_DIR_CRITICAL285 self.max_cheesecake_index_documentation += INDEX_DIR_CRITICAL308 self.max_cheesecake_index += self.INDEX_DIR_CRITICAL 309 self.max_cheesecake_index_documentation += self.INDEX_DIR_CRITICAL 286 310 else: 287 self.max_cheesecake_index += INDEX_DIR288 self.max_cheesecake_index_documentation += INDEX_DIR311 self.max_cheesecake_index += self.INDEX_DIR 312 self.max_cheesecake_index_documentation += self.INDEX_DIR 289 313 self.log.debug("cheese_dirs: " + ",".join(self.cheese_dirs)) 290 314 self.log.debug("critical_cheese_dirs: " + ",".join(self.critical_cheese_dirs)) … … 363 387 found_on_cheeseshop = False 364 388 if re.search(r"cheeseshop.python.org", download_url): 365 value = INDEX_PYPI_DOWNLOAD389 value = self.INDEX_PYPI_DOWNLOAD 366 390 found_on_cheeseshop = True 367 391 else: 368 value = INDEX_PYPI_DOWNLOAD - distance_from_pypi *INDEX_PYPI_DISTANCE392 value = self.INDEX_PYPI_DOWNLOAD - distance_from_pypi * self.INDEX_PYPI_DISTANCE 369 393 self.index[index_type].value = value 370 394 details = "downloaded package " + self.package … … 404 428 f.close() 405 429 index_type = "url_download" 406 self.index[index_type].value = INDEX_URL_DOWNLOAD430 self.index[index_type].value = self.INDEX_URL_DOWNLOAD 407 431 self.index[index_type].details = "downloaded package %s from URL %s" % (self.package, self.url) 408 432 … … 457 481 else: 458 482 details += " as expected" 459 self.index[index_type].value = INDEX_UNPACK_DIR483 self.index[index_type].value = self.INDEX_UNPACK_DIR 460 484 self.index[index_type].details = details 461 485 … … 481 505 482 506 index_type = "unpack" 483 self.index[index_type].value = INDEX_UNPACK507 self.index[index_type].value = self.INDEX_UNPACK 484 508 self.index[index_type].details = "package untar-ed successfully" 485 509 … … 514 538 515 539 index_type = "unpack" 516 self.index[index_type].value = INDEX_UNPACK540 self.index[index_type].value = self.INDEX_UNPACK 517 541 self.index[index_type].details = "package unzipped successfully" 518 542 … … 533 557 if files or dirs: 534 558 if cheese_dir in self.critical_cheese_dirs: 535 value = INDEX_DIR_CRITICAL559 value = self.INDEX_DIR_CRITICAL 536 560 details = "critical directory found" 537 561 self.log.debug("critical_cheese_dir found: " + cheese_dir) 538 562 else: 539 value = INDEX_DIR563 value = self.INDEX_DIR 540 564 details = "directory found" 541 565 self.log.debug("cheese_dir found: " + cheese_dir) 542 566 else: 543 value = INDEX_DIR_EMPTY567 value = self.INDEX_DIR_EMPTY 544 568 details = "empty directory found" 545 569 self.log.debug("empty cheese_dir found: " + cheese_dir) … … 550 574 if re.search(r"^%s(\.txt)*" % cheese_file, file, re.IGNORECASE): 551 575 if cheese_file in self.critical_cheese_files: 552 value = INDEX_FILE_CRITICAL576 value = self.INDEX_FILE_CRITICAL 553 577 details = "critical file found" 554 578 self.log.debug("critical_cheese_file found: " + cheese_file) 555 579 else: 556 value = INDEX_FILE580 value = self.INDEX_FILE 557 581 details = "file found" 558 582 self.log.debug("cheese_file found: " + cheese_file) … … 570 594 len_pyc_list = len(self.pkg_files["pyc"]) 571 595 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, 573 597 details="%d .pyc files found" % len_pyc_list) 574 598 self.log.debug("Found %d py files" % len(self.pkg_files["py"])) … … 676 700 cwd = os.getcwd() 677 701 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: 681 704 # Install succeeded 682 self.index[index_type].value = INDEX_INSTALL705 self.index[index_type].value = self.INDEX_INSTALL 683 706 self.index[index_type].details = details="package installed in %s" % self.sandbox_install_dir 684 707 else: … … 722 745 index_type = "pylint" 723 746 # 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") 727 748 if rc: 728 749 # We encountered an error … … 738 759 fullpath = os.path.join(self.sandbox, pyfile) 739 760 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) 743 762 if rc: 744 763 # We encountered an error … … 755 774 index_pylint += float(score) 756 775 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 758 780 index_value = int(ceil(avg_value*10)) 759 781 self.index[index_type].value = index_value … … 788 810 789 811 print 790 self.print_ line("=" * (PAD_TEXT + PAD_VALUE + 1))812 self.print_separator_line() 791 813 print pad_msg("OVERALL CHEESECAKE INDEX (ABSOLUTE)", self.cheesecake_index) 792 814 percentage = (self.cheesecake_index * 100) / self.max_cheesecake_index … … 807 829 partial_index_value += self.process_index(index_type) 808 830 809 self.print_ line("-" * (PAD_TEXT + PAD_VALUE + 1))831 self.print_separator_line("-") 810 832 print pad_msg("%s INDEX (ABSOLUTE)" % partial_index_name, partial_index_value) 811 833 percentage = (partial_index_value * 100) / max_value … … 828 850 return index.value 829 851 830 def print_ line(self, line):852 def print_separator_line(self, char=""): 831 853 """ 832 854 Print line of text, unless quiet flag was given … … 834 856 if self.quiet: 835 857 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 1006 860 1007 861 def process_cmdline_args(): trunk/tests/data/module1.py
r2 r8 10 10 def __init__(self): 11 11 """ 12 Methods starting with __ should be skipped12 Methods starting with __ are not kipped 13 13 """ 14 14 pass 15 15 16 16 def __another_method__(self): 17 """Should alsobe skipped"""17 """Should not be skipped""" 18 18 pass 19 19 trunk/tests/test_code_parser.py
r2 r8 1 1 import _path_cheesecake 2 from cheesecake.c heesecake_indeximport CodeParser2 from cheesecake.codeparser import CodeParser 3 3 import os 4 4 datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) … … 8 8 self.code1 = CodeParser(os.path.join(datadir, "module1.py")) 9 9 10 def test_modules(self): 11 assert self.code1.modules == ["module1"] 12 10 13 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"] 15 15 16 16 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__"] 19 21 def test_count(self): 20 assert self.code1.object_count() == 1 221 assert self.code1.docstring_count() == 1 022 assert self.code1.object_count() == 14 23 assert self.code1.docstring_count() == 12 22 24 23 25 def test_docstrings(self): 26 print self.code1.docstrings 24 27 assert self.code1.docstrings.get("module1") == 1 25 for object in [" Class1", "Class2"]:28 for object in ["module1.Class1", "module1.Class2"]: 26 29 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"]: 28 32 assert self.code1.docstrings.get(object) == 1 29 assert not self.code1.docstrings.get("m ethod4")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__"]: 31 35 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 1 1 import _path_cheesecake 2 from cheesecake.cheesecake_index import Cheesecake , INDEX_INSTALL2 from cheesecake.cheesecake_index import Cheesecake 3 3 import os 4 4 datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) … … 19 19 index = self.cheesecake.index_install() 20 20 assert index.name == "index_install" 21 assert index.value == INDEX_INSTALL21 assert index.value == self.cheesecake.INDEX_INSTALL 22 22 assert index.details == "package installed in " + self.cheesecake.sandbox_install_dir 23 23 trunk/tests/test_index_installability.py
r2 r8 1 1 import _path_cheesecake 2 from cheesecake.cheesecake_index import Cheesecake, INDEX_PYPI_DOWNLOAD,\ 3 INDEX_URL_DOWNLOAD, INDEX_UNPACK, INDEX_UNPACK_DIR, INDEX_INSTALL 2 from cheesecake.cheesecake_index import Cheesecake 4 3 import os 5 4 datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) … … 18 17 def test_index_installability_local_path(self): 19 18 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 22 23 index_types = ["pypi_download", "unpack", "unpack_dir", "install"] 23 24 cheesecake_index_installability = self.cheesecake.process_partial_index("INSTALLABILITY",\ 24 25 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 26 28 27 29 def test_index_installability_url_download(self): 28 30 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 31 34 index_types = ["pypi_download", "url_download", "unpack", "unpack_dir", "install"] 32 35 cheesecake_index_installability = self.cheesecake.process_partial_index("INSTALLABILITY",\ 33 36 index_types, self.cheesecake.max_cheesecake_index_installability) 34 assert cheesecake_index_installability == INDEX_URL_DOWNLOAD + INDEX_UNPACK + INDEX_UNPACK_DIR + INDEX_INSTALL35 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 1 1 import _path_cheesecake 2 from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, INDEX_UNPACK,pad_msg2 from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, pad_msg 3 3 import os 4 4 datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) … … 19 19 index = self.cheesecake.index_unpack() 20 20 assert index.name == "index_unpack" 21 assert index.value == INDEX_UNPACK21 assert index.value == self.cheesecake.INDEX_UNPACK 22 22 assert index.details == "package untar-ed successfully" 23 23 … … 26 26 index = self.cheesecake.index_unpack() 27 27 assert index.name == "index_unpack" 28 assert index.value == INDEX_UNPACK28 assert index.value == self.cheesecake.INDEX_UNPACK 29 29 assert index.details == "package untar-ed successfully" 30 30 … … 33 33 index = self.cheesecake.index_unpack() 34 34 assert index.name == "index_unpack" 35 assert index.value == INDEX_UNPACK35 assert index.value == self.cheesecake.INDEX_UNPACK 36 36 assert index.details == "package unzipped successfully" 37 37 trunk/tests/test_index_unpack_dir.py
r2 r8 1 1 import _path_cheesecake 2 from cheesecake.cheesecake_index import Cheesecake , INDEX_UNPACK_DIR2 from cheesecake.cheesecake_index import Cheesecake 3 3 import os 4 4 datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) … … 19 19 index = self.cheesecake.index_unpack_dir() 20 20 assert index.name == "index_unpack_dir" 21 assert index.value == INDEX_UNPACK_DIR21 assert index.value == self.cheesecake.INDEX_UNPACK_DIR 22 22 assert index.details == "unpack directory is " + self.cheesecake.package_name + " as expected" 23 23 trunk/tests/test_index_url_download.py
r2 r8 1 1 import _path_cheesecake 2 from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, INDEX_URL_DOWNLOAD,pad_msg2 from cheesecake.cheesecake_index import Cheesecake, CheesecakeError, pad_msg 3 3 4 4 import os … … 21 21 index = self.cheesecake.index_url_download() 22 22 assert index.name == "index_url_download" 23 assert index.value == INDEX_URL_DOWNLOAD23 assert index.value == self.cheesecake.INDEX_URL_DOWNLOAD 24 24 assert index.details == "downloaded package " + self.cheesecake.package + " from URL " + self.cheesecake.url 25 25 except CheesecakeError, e:
