def do(targeFilename, sourceFilename):
    target = targeFilename
    source = sourceFilename
    print("target:", target, "-----------------------------------------------------")
    print("source:", source, "-----------------------------------------------------")
    rel = absRel.RelAndCutIfNodeModules(source, target)

    # 1) get fileName by filePath
    filename = absRel.filename(target)
    # 2) create string: #{fileName} = require '#{relativePath}'
    require = "{0} = require '{1}'".format(filename, rel)
    # 3) set to cliboard objectName - filename
    # 3.1) get param names:

    # get fileContent_target to load it once:
    fileContent_target = filer2.read(target)
    # check if function sync:
    sync = callForSyncFunc.isItSync(fileContent_target)
    color.red("sync in relativeRequireIced_model.py")
    print(sync)

    isCbWithouAutocb = callForSyncFunc.isItCb(fileContent_target)

    color.red("isCbWithouAutocb in relativeRequireIced_model.py")
    print(isCbWithouAutocb)

    if isCbWithouAutocb:  # (...,cb)->
        params = getParams.getParamsCb(fileContent_target)
        ending = returnLast.getReturnParamsForAutocbCommaSeparated(fileContent_target)
        toClip = "await {0}{1} defer {2}".format(filename, params, ending)
    else:
        if sync:
            # load params sync
            params = callForSyncFunc.byFileContent(fileContent_target)
            returnParams = returnLast.returnParamsForSyncExpressionOrReturn(fileContent_target)
            toClip = "{2} = {0}{1}".format(filename, params, returnParams)
        else:  # async: (..., autocb)->
            params = getParams.getParamsAutocb(fileContent_target)

            autocbOneEnding = returnLast.autocbOneEnding(fileContent_target)
            if autocbOneEnding:
                toClip = "await {0}{1} defer {2}".format(filename, params, autocbOneEnding)
            else:
                ending = returnLast.doAllByFileName(target)
                toClip = "await {0}{1} defer result{2}".format(filename, params, ending)

    result = (require, toClip)
    return result
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
Example #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
	def test_testName(self):
		color.blue("test here baby")
		result = absRel3.filename("/a/b/c.js")
		expected = "c"
		assertMy.equals(result, expected)