def testSelectVariableIndex(self): """testSelectVariableIndex: should be able to turn off select variable index""" self.c.setLocalOveride("Select", "UseNumericIndex", "Yes") self.c.setLocalOveride("Select", "SelectVariablePrefix", "_ret") c_1 = convertVBtoPython(self.code3) self.c.setLocalOveride("Select", "UseNumericIndex", "No") c_2 = convertVBtoPython(self.code3) # # Should be different self.assertNotEqual(c_1, c_2)
def testEvalVariable(self): """testEvalVariable: should be able to change whether variable is used once or more than once""" self.c.setLocalOveride("Select", "EvaluateVariable", "Once") self.c.setLocalOveride("Select", "SelectVariablePrefix", "_ret") c_1 = convertVBtoPython(self.code3) self.c.setLocalOveride("Select", "EvaluateVariable", "EachTime") c_2 = convertVBtoPython(self.code3) # r = re.compile("_ret") self.assert_(len(r.findall(c_1)) > 1) self.assertEqual(len(r.findall(c_2)), 0)
def testFunctionVariable(self): """testFunctionVariable: should be able to change function variable""" self.c.setLocalOveride("Functions", "ReturnVariableName", "_ret") c_ret = convertVBtoPython(self.code2) self.c.setLocalOveride("Functions", "ReturnVariableName", "_other") c_other = convertVBtoPython(self.code2) # # Should be different self.assertNotEqual(c_ret, c_other) # # But only tabs and spaces self.assertEqual(c_ret, c_other.replace("_other", "_ret"))
def testRespectPrivateStatus(self): """testRespectPrivateStatus: should be able to turn off data hiding""" self.c.setLocalOveride("General", "RespectPrivateStatus", "Yes") c_on = convertVBtoPython(self.code2, container=vb2py.vbparser.VBClassModule()) self.c.setLocalOveride("General", "RespectPrivateStatus", "No") c_off = convertVBtoPython(self.code2, container=vb2py.vbparser.VBClassModule()) # # Should be different self.assertNotEqual(c_on, c_off, "Option made no difference: '%s'" % c_on) # # On should have __, off should not self.assertNotEqual(-1, c_on.find("__f"), "Yes didn't have __: '%s'" % c_on) self.assertEqual(-1, c_off.find("__f"), "No had __: '%s'" % c_off)
def testIndentAmount(self): """testSpaceOrTab: should be change between spaces and tabs""" self.c.setLocalOveride("General", "IndentAmount", 4) self.c.setLocalOveride("General", "IndentCharacter", "Space") c_four = convertVBtoPython(self.code1) self.c.setLocalOveride("General", "IndentAmount", 8) c_eight = convertVBtoPython(self.code1) # # Should be different self.assertNotEqual(c_four, c_eight) # # But only by number of spaces self.assertEqual(c_four, c_eight.replace(" ", " "))
def testSelectVariable(self): """testSelectVariable: should be able to change select variable""" self.c.setLocalOveride("Select", "UseNumericIndex", "No") self.c.setLocalOveride("Select", "SelectVariablePrefix", "_ret") c_ret = convertVBtoPython(self.code3) self.c.setLocalOveride("Select", "SelectVariablePrefix", "_other") c_other = convertVBtoPython(self.code3) # # Should be different self.assertNotEqual(c_ret, c_other) # # But only tabs and spaces self.assertEqual(c_ret, c_other.replace("_other", "_ret"))
def testSpaceOrTab(self): """testSpaceOrTab: should be change between spaces and tabs""" self.c.setLocalOveride("General", "IndentAmount", 4) self.c.setLocalOveride("General", "IndentCharacter", "Space") c_space = convertVBtoPython(self.code1) self.c.setLocalOveride("General", "IndentAmount", 1) self.c.setLocalOveride("General", "IndentCharacter", "Tab") c_tabs = convertVBtoPython(self.code1) # # Should be different self.assertNotEqual(c_space, c_tabs) # # But only tabs and spaces self.assertEqual(c_space, c_tabs.replace("\t", " "))
def testPreInitVariable(self): """testPreInitVariable: should be able to change if variable is pre initialized""" self.c.setLocalOveride("Functions", "ReturnVariableName", "_ret") self.c.setLocalOveride("Functions", "PreInitializeReturnVariable", "Yes") c_yes = convertVBtoPython(self.code2) self.c.setLocalOveride("Functions", "PreInitializeReturnVariable", "No") c_no = convertVBtoPython(self.code2) # # Should be different self.assertNotEqual(c_yes, c_no) # # With init should have _ret = None, not without self.assertNotEqual(c_yes.find("_ret = None"), -1) self.assertEqual(c_no.find("_ret = None"), -1)
def on_menuTestCode_select(self, event): """Test the code""" vb = self.components.VBCodeEditor.text self.components.PythonCodeEditor.text = convertVBtoPython(vb, container=VBCodeModule()) try: output = testCode(vb, verbose=2) except Exception, err: self.components.ResultsView.text = str(err)
def testMethod(self): local_dict = {"convertVBtoPython" : convertVBtoPython, "vbfunctions" : vbfunctions} # << Parse VB >> try: python = convertVBtoPython(vb.replace("\r\n", "\n")) except Exception, err: self.fail("Error while parsing (%s)\n%s" % (err, vb))
def testMethod(self): local_dict = {"convertVBtoPython" : convertVBtoPython, "vbfunctions" : vbfunctions} # << Parse VB >> try: python = convertVBtoPython(vb, container=container) except Exception, err: self.fail("Error while parsing (%s)\n%s" % (err, vb))
def on_menuTestCode_select(self, event): """Test the code""" vb = self.components.VBCodeEditor.text self.components.PythonCodeEditor.text = convertVBtoPython( vb, container=VBCodeModule()) try: output = testCode(vb, verbose=2) except Exception, err: self.components.ResultsView.text = str(err)
def c(*args, **kw): print convertVBtoPython(*args, **kw)