Login and get coding
Note this is a Test Bite and uses Python 3.7 and MutPy 0.6.1
In this Bite you test a simple number guessing game (class). Ready to write some
pytestcode? Read on ...
You again will need to mock out a standard library function,
We tried to use
random.randintto get the secret number, but
mutpybecame a bit too strict on us, so for now we just pass the secret number into the constructor. That said, there is some validation going on that you will need to test. Check for boundaries and to check exception strings,
raiseshas a nice
The constructor also takes an optional
max_guessesarg to make the game easier or harder. You will need to the use
capfd/capsysfixture again to test the standard output of the game (100% test coverage remember).
With all this testing goodness going on we label this an Advanced Bite, also due to the number of LOC we ended up with (> LOC of the game!). We also had to kill quite some mutants along the way (no worries, only
mutpymutants!) so well deserved the 4 points towards your next Ninja belt upon solving this one!
Good luck and keep calm and code in Python /
62 out of 68 users completed this Bite.
Will you be Pythonista #63 to crack this Bite?
Resolution time: ~101 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 7.14 on a 1-10 difficulty scale.
» Up for a challenge? 💪