Changeset 74
- Timestamp:
- 12/29/05 14:56:16 (3 years ago)
- Files:
-
- branches/timcommithook/pyramid/build.py (modified) (1 diff)
- branches/timcommithook/pyramid/test/tests.py (modified) (3 diffs)
- branches/timcommithook/pyramid/utils.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/timcommithook/pyramid/build.py
r69 r74 51 51 # dangerous remove directory contents function 52 52 if not partialbuild: 53 utils.recursiveRemoveDirectory (OUTPUTDIR)53 utils.recursiveRemoveDirectoryContents(OUTPUTDIR) 54 54 55 55 # copy in any resources needed branches/timcommithook/pyramid/test/tests.py
r68 r74 1 1 import unittest 2 from pyramid import flatteners, yamlRegistry as Y, build 2 from pyramid import flatteners, yamlRegistry as Y, build, utils, path 3 3 import os.path 4 import sys 5 import difflib 6 import wingdbstub 4 7 5 testdatadir = 'testdata'6 TEMPFOLDER = '/tmp/pyramidtest'8 testdatadir = path.path('testdata') 9 TEMPFOLDER = path.path('/tmp/pyramidtest') 7 10 8 11 def removeTemp(dir): 9 if os.path.isdir(dir): 12 if os.path.isdir(dir) and dir.startswith(TEMPFOLDER): 13 utils.recursiveRemoveDirectoryContents(dir) 10 14 os.rmdir(dir) 15 else: 16 print 'cant remove %s' % dir 17 sys.exit() 11 18 12 19 def makeAndCleanTemp(dir): 13 removeTemp(dir) 20 if os.path.exists(dir): 21 removeTemp(dir) 14 22 os.mkdir(dir) 15 23 … … 53 61 54 62 buildtestroot = 'build_tests' 55 testfolders = ['basic']63 buildtestpath = path.path(os.getcwd()) / 'pyramid' / 'test' / testdatadir / buildtestroot 56 64 57 65 def setUp(self): … … 64 72 """ 65 73 """ 66 for folder in self.testfolders: 67 fullpath = os.path.join(os.getcwd(),'pyramid','test',testdatadir,self.buildtestroot,folder) 68 fullpathCorrectResuts = os.path.join(os.getcwd(),'pyramid','test',testdatadir,self.buildtestroot,'%s-checked'%folder) 69 build.build(fullpath,TEMPFOLDER) 74 skipdirs = ['.svn'] 75 tests = [d for d in os.listdir(self.buildtestpath) if d != '.svn'] 76 77 for buildtest in tests: 78 79 datapath = self.buildtestpath / buildtest / 'data' 80 checkedresultpath = self.buildtestpath / buildtest / 'expected' 81 checkedresultwithcachepath = self.buildtestpath / buildtest / 'withcache' 82 build.build(datapath,TEMPFOLDER / buildtest) 83 84 def compareDirs(actual,expected,skipdirs=[],skipfiles=[]): 85 for root, dirs, files in os.walk(checkedresultpath): 86 relpath = checkedresultpath.relpathto(root) 87 for dir in dirs: 88 if dir in skipdirs: 89 dirs.remove(dir) 90 for file in files: 91 if file not in skipfiles: 92 93 filetext1 = open(TEMPFOLDER / buildtest / relpath / file).readlines() 94 filetext2 = open(checkedresultpath / relpath / file).readlines() 95 d = difflib.Differ() 96 result = list(difflib.context_diff(filetext1,filetext2)) 97 if len(result) > 0: 98 print '\n'.join(result) 99 return False 100 return True 101 102 self.assertEqual(compareDirs(TEMPFOLDER / buildtest,checkedresultpath,skipdirs,['.cache.dump']),True) 103 self.assertEqual(compareDirs(TEMPFOLDER / buildtest,checkedresultwithcachepath,skipdirs),True) 104 105 106 70 107 71 108 branches/timcommithook/pyramid/utils.py
r1 r74 56 56 return lstripline, len(line)-len(lstripline) 57 57 58 def recursiveRemoveDirectory (dir):58 def recursiveRemoveDirectoryContents(dir): 59 59 for root, dirs, files in os.walk(dir, topdown=False): 60 60 for name in files:
