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.
Python Scripting to format data
Hey guys, I got this script for doing a format, but I get an error that I can't reconcile. The error states that The Method Takes only one Argument. I've looked for the ValueMap function in the API docs but can't find it. Does anything look out of the ordinary for this script?
def formatPhoneNumber(input, context):
# get the phone number from the data bank in the form of 9122000107 for example.
# Change the string "Test 3: prefix" to point to the column that the test1 data bank puts the phone number in
value = context.getValue("Generated Data Source", "Test 3: prefix");
# parse the number to get all the sub components
areaCode = (str(value))[0:2]
phoneNumber1 = (str(value))[3:5]
phoneNumber2 = (str(value))[6:9]
# Store the formatted phone number into the map of data banked values.
# Modify the string "Test 1: x" to make it point to the data banked column name. In my test case, the phone number
# was stored under the name "Test 1: x"
valueMap = context.getGeneratedDataSourceValues()
valueMap.put("Test 3: prefix", "(%s)%s-%s" % (areaCode, phoneNumber1, phoneNumber2))
Method takes only one argument.
Thanks in advance,