Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Unable to add a assertion by custom scripting

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
I am trying to check if a number if positive or not by using XML asserter.

After I have written the code I should get the function name in the Method drop down. But I am not able to see that. The drop down is empty. I have attached a screen shot for the same.

Can someone please help me in resolving this?

Regards
Archana
Tagged:

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hi Archana,

    I notice two things about the script:

    1) The indents are inconsistent, which is actually invalid syntax in Python. In particular, the if-else statement should be indented consistently. Python uses indentation to determine program structure.

    2) The else statement should have a colon ( : ) after it.

    Note that an easier implementation would be something like this:
    CODE
    def checkid(input, context):
        id = float(input)
        return id > 0
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Thanks a lot. I am new to Pyhton so did not know that there would be errors due to indntations.The code is working fien now.

    Thanks
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    You don't need to use scripting. You can create a Numeric Assertion with:

    Element must be: >
    Expected value (Fixed): 0