Forum Discussion

strp's avatar
strp
New Contributor
10 years ago

[python] check for 'item not in mylist' causes TestComplete to crash

 

 

I am trying to build a list of backpointers. In there, I want to avoid duplicates. As far as i know i cant use a dict or set, because the items to be stored are not hashable. I implented the following code:

 

while k in range(limit):
    try:
        if path not in path_backp:
path_backp.append(path) continue else: Log.Message(path.Item[k].Text)
path = path.Item[k].Items
limit = path.Count scan(path, path_backp, e, 0)
k = k +1 except AttributeError:
path = path_backp.pop()
limit = path.Count
k = k + 1

 

the part to avoid double entities of course is:

 

if path not in path_backp:
path_backp.append(path) continue else: [...]

 

Im running python inside TestComplete, which has (limited) debugging functions. When I enable the debugger and track what is happening, the first check works. The if-routine gets executed, and because path_backp is an empty dict, path gets appended, so that afterwards path_backp[0] equals path and I get back to to the while-routine. But when the if-routine gets executed the 2nd time (so when path_backp is no empty dict anymore), the debugger freezes for what seems an infinite amount of time.

same happens, by the way, when I implemented:

 

if path not in path_backp:    
path_backp
.append(path)

 

without any continue or else.

Can anyone explain to me why this is happening and how I can handle the situation?

Many thanks,

 

t.

  • strp According to our Devs, it makes sense to check how TestComplete 11.30 works for you. Give it a try and let me know the result, so we determine the next steps.

  • If you can share a simple (self-contained) example here that reproduces your problem, it would be easier for us to see the possible cause.