need data structure to for test results analysis

T

terry433iid

I have a python program that reads test result information from SQL and creates the following data that I want to capture in a data structure so it can be prioritized appropriately :-

test_name new fail P1
test_name known fail (but no bug logged) P2
test_name known fail (bug logged but is closed) P3
test_name known fail (bug is open) P4




If I run my script I will get one of these types of failures - PLUS the number of occurrences of each type, sample data as follows:-
P1 new fail | occurrence once (obviously)
P1 new fail | occurrence once (obviously)
P1 new fail | occurrence once (obviously)
P1 new fail | occurrence once (obviously)
P2 known fail | occurred previously 10 times in earlier executions
P2 known fail | occurred previously 15 times in earlier executions
P2 known fail | occurred previously 16 times in earlier executions
P2 known fail | occurred previously 5 times in earlier executions
P3 known fail | occurred previously 6 times in earlier executions
P4 known fail | occurred previously 1 times in earlier executions
P4 known fail | occurred previously 12 times in earlier executions
..
..
..
etc



I want to be store this in an appropriate structure so I can then so some analysis :-
if (all reported fails are "new fail"):
this is priority 1
if (some fails are "new fail" and some are known (P2/P3/P4):
this is priority 2
if (no new fail, but all/some reported fails are "P2 known fail")
this is priority 3
if ( all/some reported fails are "P3 known fail")
this is priority 4
if ( all/some reported fails are "P4 known fail")
this is priority 4

I have tried using dictionary/lists but can't get the exact final outcome I want, any help appreciated....
 
J

Joshua Landau

I have a python program that reads test result information from SQL and creates the following data that I want to capture in a data structure so it can be prioritized appropriately :-

test_name new fail P1
test_name known fail (but no bug logged) P2
test_name known fail (bug logged but is closed) P3
test_name known fail (bug is open) P4




If I run my script I will get one of these types of failures - PLUS the number of occurrences of each type, sample data as follows:-
P1 new fail | occurrence once (obviously)
P1 new fail | occurrence once (obviously)
P1 new fail | occurrence once (obviously)
P1 new fail | occurrence once (obviously)
P2 known fail | occurred previously 10 times in earlier executions
P2 known fail | occurred previously 15 times in earlier executions
P2 known fail | occurred previously 16 times in earlier executions
P2 known fail | occurred previously 5 times in earlier executions
P3 known fail | occurred previously 6 times in earlier executions
P4 known fail | occurred previously 1 times in earlier executions
P4 known fail | occurred previously 12 times in earlier executions
.
.
.
etc

I'm assuming you can put this into a list like:

failures = [failure1, failure2, failure3, ...]

A failure can be represented by a "namedtuple" or a class or some
other thing. For simplicity, I'll use a class:

class Failure:
def __init__(self, name, type):
self.name, self.type = name, type

def __repr__(self):
return "Failure({}, {})".format(self.name, self.type)
I want to be store this in an appropriate structure so I can then so some analysis :-
if (all reported fails are "new fail"):
this is priority 1
if (some fails are "new fail" and some are known (P2/P3/P4):
this is priority 2
if (no new fail, but all/some reported fails are "P2 known fail")
this is priority 3
if ( all/some reported fails are "P3 known fail")
this is priority 4
if ( all/some reported fails are "P4 known fail")
this is priority 4

I have tried using dictionary/lists but can't get the exact final outcome I want, any help appreciated....

You have your list of Failure()s, so you can do:

if all(fail.type == "new fail" for fail in failures):
set_priority_1()

elif any(fail.type == "new fail" for fail in failures):
set_priority_2()

elif any(fail.type == "P2 known fail" for fail in failures):
set_priority_3()

elif any(fail.type == "P3 known fail" for fail in failures):
set_priority_4()

elif any(fail.type == "P4 known fail" for fail in failures):
set_priority_4()

else:
freak_out()


If you want something else, I'm not sure what you're asking.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top