robotframework - Python module does not work as expected, if used as custom keyword in Robot Framework -


if call pathon function console, dates calculated expected:

def get_nearest_date(day, month):     """gets nearest date in future provided day , month."""     today = date.today()     res = ""     if (today.month < month):         res = str(day) + "." + str(month) + "." + str(today.year)     elif ((today.month == month) & (today.day < day)):         res = str(day) + "." + str(month) + "." + str(today.year)     else:          res = str(day) + "." + str(month) + "." + str((today.year + 1))     return res 

for example:

print   get_nearest_date(1, 1) print   get_nearest_date(1, 12) 

returns

1.1.2016 1.12.2015 

but if use function custom keyword in robot framework testcase this

bla         ${d} =    nearest date    1   1     log console  ${d}     ${d} =    nearest date    1   12     log console  ${d} 

it prints

bla                                                                    1.1.2015 1.12.2015 

which wrong (first date should 2016). why this?

it took me time realise in rf parameters passed custom keyword

${d} =    nearest date    1   1 

are strings. passing number variables solves issue:

${d} =    nearest date     ${1}    ${1} 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -