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
pytest
code? Read on ...You again will need to mock out a standard library function,
input
this time.We tried to use
random.randint
to get the secret number, butmutpy
became 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,pytest
'sraises
has a nicematch
kwarg.The constructor also takes an optional
max_guesses
arg to make the game easier or harder. You will need to the usecapfd/capsys
fixture 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
mutpy
mutants!) so well deserved the 4 points towards your next Ninja belt upon solving this one!Good luck and keep calm and code in Python /
pytest
.
64 out of 70 users completed this Bite.
Will you be the 65th person to crack this Bite?
Resolution time: ~101 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 7.14 on a 1-10 difficulty scale.
» Up for a challenge? 💪