Forum Discussion

tphillips's avatar
tphillips
Frequent Contributor
3 years ago
Solved

Code Snippet operation with Python has syntax error when assigning variable value

Hi   I am have made a new TestComplete project and I have found that the Code Snippet keyword test step fails with a syntax error when a variable is being assigned to:   I have notice...
  • tphillips's avatar
    tphillips
    3 years ago

    I got a response from support:

    "It appears that this code works perfectly fine in a script unit, but does not want to behave in the "run code snippet" operation. I was able to get it to work by wrapping it in exec("..."). For example, replace your code snippet operation with exec("KeywordTests.Test_Assigning.Variables.TestVar = 'String2'")"

     

    I tried it out and it works fine. I guess this should be documented for python-specific weirdness?