-4

I have a very simple problem here. I want to achieve the following VB script Code in Python:-

dim objSfact 
dim objOrun 
dim mystep 
Set objOrun = QCutil.CurrentRun 
Set objSfact = objOrun.StepFactory 
Set att = objSfact.AddItem(null) 
att.name = aStepname 
att.post 
Set steplist = objSfact.NewList("SELECT * FROM Step 
WHERE 
ST_STEP_NAME='" & aStepname & "'") 
For each mystep in steplist 
        mystep.Status = aStatus 
        myStep.Field("ST_DESCRIPTION") = aDesc 
        myStep.Field("ST_EXPECTED") = aExpected 
        mystep.Field("ST_ACTUAL") = aActual 
        If mystep.Status = "Failed" then 
                objOrun.Status = "Failed" 
        end if 
        mystep.Post 
Next 
Set objSfact = Nothing 
Set objOrun = Nothing 

Particularly, I cannot do this in Python - mystep.Field("ST_ACTUAL") = aActual ; because I get the following error- "SyntaxError: can't assign to function call" Any help? Thanks, Amit

UPDATES: Please, the python script can be found here... Adding testcase results to Quality Center Run from a outside Python Script

Community
  • 1
  • 1
amulllb
  • 3,036
  • 7
  • 50
  • 87
  • 2
    It would be tremendously useful to see the python code you've tried. – matt b Oct 14 '11 at 20:12
  • Please look at this link- http://stackoverflow.com/questions/7773430/adding-testcase-results-to-quality-center-run-from-a-outside-python-script – amulllb Oct 14 '11 at 21:00

2 Answers2

2

In Python () represent calls to functions, while [] represent indexing and mapping.

Ethan Furman
  • 63,992
  • 20
  • 159
  • 237
  • In other words, Python thinks you're trying to call a function, when what you're probably trying to do is index a collection. In other words, use [] instead of (). – Robert Harvey Oct 15 '11 at 16:12
  • It doesn't work because, due to the COM interface of Python, 'Field' is treated as a method and we cannot use [] against a method. – amulllb Oct 18 '11 at 15:52
0

I have the answer here: Adding testcase results to Quality Center Run from a outside Python Script

Basically, instead of mystep.Field("ST_ACTUAL") = aActual, I can simply do this mystep.SetField("ST_ACTUAL", "my actual result")

Community
  • 1
  • 1
amulllb
  • 3,036
  • 7
  • 50
  • 87