def test_testName(self): color.blue("test here baby") inputText = """ def test_testName(self): color.blue("test here baby") intpuText = beatyModel.py(inputText) def test_testName(self): color.blue("test here baby") intpuText = beatyModel.py(inputText)""" filename = os.path.join(currentFolder, 'files/poligon') filer.write(filename, inputText) expected = """\tdef test_testName(self): color.blue("test here baby") intpuText = beatyModel.py(inputText) def test_testName(self): color.blue("test here baby") intpuText = beatyModel.py(inputText) """ beatyModel.pyFile(filename) result = filer.read(filename) color.red("inputText") print(repr(inputText)) print(inputText) assertMy.stringDiffByLines(result, expected)
def test_recursiveWrite(self): color.blue("test here baby") inputFileContent = """routes = require '../../routes/e' rrnt = require '../f.iced' db = require 'db' module.exports = (url, param, test)-> rrnt routes, url, param, test """ # expected = """routes = require '../e.iced' # rrnt = require './k/f.iced' # db = require 'db' # module.exports = (url, param, test)-> # rrnt routes, url, param, test # """ path = "/Users/maks/Library/Application Support/Sublime Text 3/Packages/goodPath/forRecursiveTest" files = recursiveSearch_model.getAllFiles(path) for fileName in files: filer.write(fileName, inputFileContent) findAllRelative_model.repaireRecursive(path) for fileName in files: result = filer.read(fileName) self.assertNotEqual (result, inputFileContent)
def test_testName(self): color.blue("test here baby") inputText = """if inlist: print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') color.red('inlist') print(inlist) print('*****************************************************************') currentIndex = allList.index(current) #todo: make test to test when current item not in list chooseNumber = currentIndex + 1 if chooseNumber >= len(allList):""" filename = os.path.join(currentFolder, 'files/printColor.poligon') filer.write(filename, inputText) clear.pyFile(filename) result = filer.read(filename) expected = """if inlist: currentIndex = allList.index(current) #todo: make test to test when current item not in list chooseNumber = currentIndex + 1 if chooseNumber >= len(allList):""" print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') color.red('expected') print(expected) print('*****************************************************************') self.assertEqual(result, expected)
def run(self): clip = sublime.get_clipboard() fileName = '/Users/maks/temp' filer.write(fileName, clip) self.window.open_file(fileName, sublime.ENCODED_POSITION) self.window.run_command("go_to_line", {'line':'0'})
def test_testName(self): color.blue("test here baby") inputText = """import sublime import sublime_plugin import os from os import listdir from os.path import isfile, join import sys sys.path.insert(0, '/Users/maks/Library/Application Support/Sublime Text 3/Packages/goodPath') import findAllRelative_model class repaire_relative_paths_plugin_Command(sublime_plugin.WindowCommand): def run(self): print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') print("new run repaire_relative_paths_plugin_") print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') window = self.window view = window.active_view() filename = view.file_name() findAllRelative_model.goAndWrite(filename) sublime.status_message("repaire_relative_paths_plugin done") """ filename = os.path.join(currentFolder, 'files/printColor.poligon') filer.write(filename, inputText) clear.pyFile(filename) result = filer.read(filename) color.red('result') print(repr(result)) expected = """import sublime import sublime_plugin import os from os import listdir from os.path import isfile, join import sys sys.path.insert(0, '/Users/maks/Library/Application Support/Sublime Text 3/Packages/goodPath') import findAllRelative_model class repaire_relative_paths_plugin_Command(sublime_plugin.WindowCommand): def run(self): window = self.window view = window.active_view() filename = view.file_name() findAllRelative_model.goAndWrite(filename) sublime.status_message("repaire_relative_paths_plugin done")""" color.red('expected') print(expected) assertMy.stringDiffByLines(result, expected )
def test_writeFile(self): path = os.path.join(currentFolder, '../writeThisFile.iced') filer.write(path, "") empty_expected = filer.read(path) self.assertEqual (empty_expected, "") actualValue = """ 3 4 5""" filer.write(path, actualValue) mustEqualToActual = filer.read(path) self.assertEqual(mustEqualToActual, actualValue)
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
def test_goAndWrite(self): color.blue("test here baby") inputFileContent = """routes = require '../../routes/e' rrnt = require '../f.iced' db = require 'db' module.exports = (url, param, test)-> rrnt routes, url, param, test """ path = "/Users/maks/Library/Application Support/Sublime Text 3/Packages/goodPath/forTest/a/b/c/testForWrite.iced" filer.write(path, inputFileContent) findAllRelative_model.goAndWrite(path) expected = """routes = require '../e.iced' rrnt = require './k/f.iced' db = require 'db' module.exports = (url, param, test)-> rrnt routes, url, param, test """ result = filer.read(path) self.assertEqual (result, expected)
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 pyFileFull(filename): text = filer.read(filename) result = pyFull(text) if (result != text): filer.write(filename, result)
def goAndWrite(filePath): newContent = go(filePath) filer.write(filePath, newContent)
def setAll(self, li): filer.write(self.dataFile(), li)
def pyFile(filename): fileText = filer.read(filename) fileText = py(fileText) filer.write(filename, fileText)
def clear(self): filer.write(self.dataFile(), [])
def currentSet(self, current): filer.write(self.currentFile(), [current])
def add(self, filenameLine): data = self.all() data = data + [filenameLine] filer.write(self.dataFile(), data)
def Replace2(oldPath, newPath): fileContent = filer.read (newPath) newContent = Replace(oldPath, newPath, fileContent) color.blue ("newContent") filer.write(newPath, newContent)
def writeFile(data): filer.write(fileName, data)