コード例 #1
0
 def test_f5_startvalues_fromfile_no_file(self):
     """
     Test creating gamefield from file with pattern.
     When no such file exist
     """
     with self.assertRaises(FileNotFoundError):
         cg.startvalues_fromfile("no_such_file")
コード例 #2
0
 def test_e4_startvalues_fromfile_smalldiffsize(self):
     """
     Test creating gamefield from file with pattern.
     When gamefield is smaller and pattern size diff between
     rows and cols
     """
     config.NR_ROWS = 5  # len of beacon is 6
     config.NR_COLS = 5  # len of beacon[0] is 6
     with self.assertRaises(ValueError):
         cg.startvalues_fromfile("beehive")
コード例 #3
0
 def test_e2_startvalues_fromfile_samesize(self):
     """
     Test creating gamefield from file with pattern.
     When gamefield is same size as pattern.
     """
     config.NR_ROWS = 6  # len of beacon
     config.NR_COLS = 6  # len of beacon[0]
     gamefield = cg.startvalues_fromfile("beacon")
     self.assertEqual(gamefield, self.beacon_s)
コード例 #4
0
 def test_e3_startvalues_fromfile_smallersize(self):
     """
     Test creating gamefield from file with pattern.
     When gamefield is smaller
     """
     config.NR_ROWS = 5  # len of beacon is 6
     config.NR_COLS = 5  # len of beacon[0] is 6
     gamefield = cg.startvalues_fromfile("beacon")
     self.assertEqual(gamefield, self.beacon_s)
コード例 #5
0
 def test_e1_startvalues_fromfile_biggersize(self):
     """
     Test creating gamefield from file with pattern.
     When gamefield is bigger than pattern
     """
     config.NR_ROWS = 10
     config.NR_COLS = 10
     gamefield = cg.startvalues_fromfile("beacon")
     self.assertEqual(gamefield, [
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 1, 1, 0, 0, 0, 0, 0],
         [0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
         [0, 0, 0, 0, 0, 1, 1, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     ])