I'm trying to unit test my minesweeper game made in python. I am starting small with just 1 test on 1 definition, but it runs the entire code of which I should be testing a very minor part. Unit testing code:
import unittest
from minesweeper import setupgrid
class Testmyfunctions(unittest.TestCase):
def test_setup(self):
self.assertTrue(setupgrid(9, [], 10))
if __name__ == '__main__' :
unittest.main(exit=False)
And this is the function it should be checking:
import random, re, time
from string import ascii_lowercase
def setupgrid(gridsize, start, numberofmines):
emptygrid = [['0' for i in range(gridsize)] for i in range(gridsize)]
mines = getmines(emptygrid, start, numberofmines)
for i, j in mines:
emptygrid[i][j] = 'X'
grid = getnumbers(emptygrid)
return (grid, mines)
The default values for emptygrid and numberofmines are, respectively, 9 and 10 and the value for start should be empty, hence the [].