def create(filename, methodName, testFileContent):
    dirName = absRel3.folder(filename)  
    testFolder = os.path.join(dirName)
    if not os.path.exists(testFolder): os.makedirs(testFolder)

    testMethodName = getTestMethodName(methodName)

    (testFile, i) = createFileNameForGoTest(testFolder, testMethodName)

    

    justFileName = absRel3.filename(filename)


    
    # testText = createTestFileContent(packageName, testMethodName, methodName)
    filer2.write(testFile, testFileContent)
    return testFile
예제 #2
0
    def find(self, filename, position):

        text = filer2.read(filename)
        [obj, method] = navigateToModel.getObject(text, position)

        

        mypath = absRel3.folder(filename)
        
        targetFiles = []
        for (dirpath, dirnames, filenames) in walk(mypath):

            targetFiles.extend([ os.path.join(dirpath, f) for f in filenames if absRel3.Ext(f) == 'py'])

        regex = "{}.\(".format(method)
        regex = re.compile(regex)       
        
        returnList = []     
        for f in targetFiles:
            # text = filer2.read(f)
            positions = navigateToModel.getPositions(f, regex)      
            if positions:
                returnList.extend([(f, p) for p in positions])

        
        self.i.setAll(returnList)



        if returnList:
            current = returnList[-1]
            (f,p) = current
            self.i.currentSet("{0}{1}".format(f,p))
            
            count = len(returnList)
            
            status = "{0} of {1}".format(count, count)
            # current.insert(2, status)
            current += (status,)
        else:
            status = "no found"
            current = None  
        return current  
예제 #3
0
def create(filename, methodName):
	### get filename's folder name ###
	dirName = absRel3.folder(filename)	
	### generate test folder abs path ###
	testFolder = os.path.join(dirName, "test")
	### if test folder do not exists create it: ###
	if not os.path.exists(testFolder): os.makedirs(testFolder)
	### generate test file name ###
	testFile = createFileName(testFolder, methodName)
	### from full filename get just filename ###
	justFileName = absRel3.filename(filename)
	### test file content ###
	testText = """import unittest
import sys
sys.path.insert(0, '/Users/maks/Library/Application Support/Sublime Text 3/Packages/util')
sys.path.insert(0, '{0}')
import color
import assertMy
import {1}

class Test(unittest.TestCase):
	def test_testName(self):
		color.blue("test here baby")
		result = {1}.{2}()
		expected = ""
		assertMy.equals(result, expected)

if __name__ == '__main__':
	unittest.main()"""
	testText = testText.format(dirName, justFileName, methodName)




	filer2.write(testFile, testText)
	return testFile
예제 #4
0
def writeEvenIfNoDir(path, content):
    directory = absRel3.folder (path)
    if not os.path.exists(directory):
        os.makedirs(directory)  
    write (path, content)      
예제 #5
0
	def test_testName(self):
		color.blue("test here baby")
		filename = "/asdf/adfa/d"
		result = absRel3.folder(filename)
		expected = "/asdf/adfa"
		self.assertEqual(result, expected)