Deleting added TestedApps shows strange behaviour in python
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Deleting added TestedApps shows strange behaviour in python
Hi,
I've just noticed something odd.
Our test application is adding a list of TestedApps for use and to be sure no apps are added twice, we purge all existing TestedApps first. This works when we're using JScript or CScript like this:
function del_applications()
{
// Delete all TestedApps
var count = TestedApps["Count"];
for(var i = 0; i < count ; i++)
{
TestedApps["Delete"](0);
}
}
Using Pyhon however gives a strange behaviour. This is the python script:
def del_applications():
# Deletes all TestedApps
count = TestedApps.Count
for i in range(count):
TestedApps.Delete(i)
The python script deletes exactly half of the applications, then the next time I run it, it deletes half of the remaining applications. I can do this until eventually I have deleted all the applications in TestedApps.
I'm using TestComplete 14.91.341.7 x64 on Windows 10 Standard, 64-bit (10.0 Build 17763)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just curious, why not just create a list of Tested Apps once and leave it there?
Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah, why not?
Legacy is the short and long answer. We probably can work around it, but since our test suite is a decade old by now the risk of breaking something is holding us back...
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I know.
I can work around it.
I'm curious about the reason for Python not being able to delete more than half of the TestedApps in one go, though.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @stein_oddvar_ra -
Is the count in the python script returning the full number of applications?
Emma
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @ebarbera
Yes it does. I use the TestedApps.Count value to set the number of times to iterate. The code is simple:
def del_applications():
# Deletes all applications from the TestedApps
numApps = TestedApps.Count
Log.Message(f"Deleting {numApps} apps from TestedApps.")
for i in range(numApps):
if not TestedApps.Delete(i):
Log.Warning(f"Could not delete app index {i} from TestedApps")
It logs the correct number of apps, but deletes only the first half of them. The rest fails.
The bug is present in TestComplete 15.10.445.7
