def testStringMethodWithParameters(self): pyutMethod: PyutMethod = self._pyutMethod PyutMethod.setStringMode(PyutGloballyDisplayParameters.WITH_PARAMETERS) self.assertEqual(PyutGloballyDisplayParameters.WITH_PARAMETERS, pyutMethod.getStringMode(), 'Did not get set correctly')
def testCreatePropertiesReadOnly(self): propName: str = 'fontSize' setterParams: List[str] = [] setter, getter = self.reverseEngineer._createProperties( propName=propName, setterParams=setterParams) PyutMethod.setStringMode(PyutGloballyDisplayParameters.WITH_PARAMETERS) self.assertIsNone(setter) self.assertIsNotNone(getter)
def showParams(self, val): """ Choose whether to show the params in the classes or not. @param val @since 1.17 @author L. Burgbacher <*****@*****.**> """ if val: PyutMethod.setStringMode(WITH_PARAMS) else: PyutMethod.setStringMode(WITHOUT_PARAMS)
def showParams(self, theNewValue: bool): """ Globally choose whether to show the method parameters in classes Args: theNewValue: """ if theNewValue is True: PyutMethod.setStringMode( PyutGloballyDisplayParameters.WITH_PARAMETERS) else: PyutMethod.setStringMode( PyutGloballyDisplayParameters.WITHOUT_PARAMETERS)
def testStringMethodWithParametersRepresentation(self): pyutMethod: PyutMethod = self._pyutMethod pyutMethod.returnType = PyutType('float') pyutMethod.parameters = self._makeParameters() PyutMethod.setStringMode(PyutGloballyDisplayParameters.WITH_PARAMETERS) defaultName: str = PyutPreferences().methodName expectedRepresentation: str = f'+{defaultName}(intParam: int = 0, floatParam: float = 32.0): float' actualRepresentation: str = pyutMethod.__str__() self.assertEqual(expectedRepresentation, actualRepresentation, 'Oops this does not match')
def testCreatePropertiesNormal(self): PyutMethod.displayParameters = PyutGloballyDisplayParameters.WITH_PARAMETERS propName: str = 'fontSize' setterParams: List[str] = ['newSize:int'] setter, getter = self.reverseEngineer._createProperties( propName=propName, setterParams=setterParams) PyutMethod.setStringMode(PyutGloballyDisplayParameters.WITH_PARAMETERS) self.logger.info( f'setter={setter.__str__()} getter={getter.__str__()}') self.assertEqual('+fontSize(newSize: int): ', setter.getString(), 'Incorrect setter generated') self.assertEqual('+fontSize(): int', getter.getString(), 'Incorrect getter generated')