MCPcopy Create free account
hub / github.com/F-Stack/f-stack / Statistics

Class Statistics

dpdk/dts/framework/test_result.py:66–99  ·  view source on GitHub ↗

A helper class used to store the number of test cases by its result along a few other basic information. Using a dict provides a convenient way to format the data.

Source from the content-addressed store, hash-verified

64
65
66class Statistics(dict):
67 """
68 A helper class used to store the number of test cases by its result
69 along a few other basic information.
70 Using a dict provides a convenient way to format the data.
71 """
72
73 def __init__(self, dpdk_version: str | None):
74 super(Statistics, self).__init__()
75 for result in Result:
76 self[result.name] = 0
77 self["PASS RATE"] = 0.0
78 self["DPDK VERSION"] = dpdk_version
79
80 def __iadd__(self, other: Result) -> "Statistics":
81 """
82 Add a Result to the final count.
83 """
84 self[other.name] += 1
85 self["PASS RATE"] = (
86 float(self[Result.PASS.name]) * 100 / sum(self[result.name] for result in Result)
87 )
88 return self
89
90 def __str__(self) -> str:
91 """
92 Provide a string representation of the data.
93 """
94 stats_str = ""
95 for key, value in self.items():
96 stats_str += f"{key:<12} = {value}\n"
97 # according to docs, we should use \n when writing to text files
98 # on all platforms
99 return stats_str
100
101
102class BaseResult(object):

Callers 1

processMethod · 0.85

Calls

no outgoing calls

Tested by 1

processMethod · 0.68