Ziyuan Ma Ziyuan Ma - 4 years ago 80
Python Question

"Not all arguments converted during string formatting" while checking list

Well, I am writing a test script and trying to find out if one stuff is inside the window object list:

Here is part of my code:

...
final_list=self.coveroff(all_list)
logger.info("coveroffed list")
if 'lblPressUpdatetosearchforsubscriptions' in final_list:
logger.info("Success to find the lable PressUpdatetosearchforsubscriptions" % case_name)
else:
logger.info("Unable to find the lable PressUpdatetosearchforsubscriptions" % case_name)
...


and here is the log:

....INFO: covering off
....INFO: covered off
....INFO: coveroffed list
....ERROR: Test Failed - ERROR Message:not all arguments converted during string formatting


And I tested to put out the final_list ,

object ' lblPressUpdatetosearchforsubscriptions ' is truly inside the list !

So why can't I check it out in test script ? Am I had wrong code ?

Begging for help...

Answer Source

You must use %s placeholder inside the quotes if you decided to put case_name

if 'lblPressUpdatetosearchforsubscriptions' in final_list:
    logger.info("Success to find the lable PressUpdatetosearchforsubscriptions case name:%s" % case_name)
else:
    logger.info("Unable to find the lable PressUpdatetosearchforsubscriptions case name:%s" % case_name)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download