avatar Bite 235. Which Bite has the fastest tests?

In this Bite you will parse a pytest output summary, calculating the Bite that has the fastest average tests.

Log snippet (full log):

01 =========================== 2 passed in 0.06 seconds ===========================
02 =========================== 6 passed in 0.04 seconds ===========================
03 =========================== 4 passed in 0.74 seconds ===========================
04 =========================== 2 passed in 0.96 seconds ===========================
...

You need to parse out the first number, which is the Bite, the number tests executed (only look at passing tests!), and the seconds it took. Return the Bite number that had the fastest average runtime per test.

For example:

>>> lines
['01 =========================== 2 passed in 0.06 seconds ===========================',
 '02 =========================== 6 passed in 0.04 seconds ===========================',
 '03 =========================== 4 passed in 0.74 seconds ===========================',
 '04 =========================== 2 passed in 0.96 seconds ===========================']
>>> get_bite_with_fastest_avg_test(lines)
'02'

Which is a clear winner if you do the math:

>>> 0.06/2  # bite 01
0.03
>>> 0.04/6  # bite 02
0.006666666666666667  <== Bite with fastest average
>>> 0.74/4  # bite 03
0.185
>>> 0.96/2  # bite 04
0.48

So a bit of text parsing, calculation and sorting in this Bite. Have fun and keep calm and code in Python!

Login and get coding
go back Intermediate level
Bitecoin 3X

Will you be Pythonista #55 to crack this Bite?
Resolution time: ~61 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 5.44 on a 1-10 difficulty scale.
» Up for a challenge? 💪

We use Python 3.8