Пример #1
0
 def test_dig(self):
     for t in ('complete', 'mine', 'small'):
         with self.subTest(test=t):
             with open("test_outputs/test_dig%s.json" % t) as f:
                 expected = json.load(f)
             with open("test_inputs/test_dig%s.json" % t) as f:
                 inputs = json.load(f)
             game = inputs["game"]
             result = {"revealed": lab.dig(game, inputs["row"], inputs["col"]), "game": game}
             self.assertEqual(result, expected)
Пример #2
0
def integration_test(game, coords):
    results = []
    for coord in coords:
        results.append([("dig", lab.dig(game, *coord)),
                        ("board", deepcopy(game)),
                        ("render", lab.render(game)),
                        ("render/xray", lab.render(game, True)),
                        ("render_ascii", lab.render_ascii(game)),
                        ("render_ascii/xray", lab.render_ascii(game, True))])
    return results
Пример #3
0
 def test_integration(self):
     """ dig, render, and render_ascii on boards """
     for t in range(1, 4):
         with self.subTest(test=t):
             with open("test_outputs/test_integration%d.json" % t) as f:
                 expected = json.load(f)
             with open("test_inputs/test_integration%s.json" % t) as f:
                 inputs = json.load(f)
             results = []
             game = inputs['game']
             for coord in inputs['coords']:
                 results.append([["dig", lab.dig(game, *coord)],
                                 ["board", deepcopy(game)],
                                 ["render", lab.render(game)],
                                 ["render/xray", lab.render(game, True)],
                                 ["render_ascii", lab.render_ascii(game)],
                                 ["render_ascii/xray", lab.render_ascii(game, True)]])
             self.assertEqual(results, expected)
Пример #4
0
def ui_dig(d):
    game, row, col = d["game"], d["row"], d["col"]
    status, nb_dug = lab.dig(game, row, col)
    return [game, status, nb_dug]
Пример #5
0
def dig(game, *args): # Dig mutates game in place
    result = lab.dig(game, *args)
    return [result, game]