コード例 #1
0
ファイル: wrapper.py プロジェクト: jma100/MIT-6.009-lab_4
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
コード例 #2
0
ファイル: test.py プロジェクト: chasecreates/MIT-6.009
 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)
コード例 #3
0
ファイル: test.py プロジェクト: chasecreates/MIT-6.009
 def test_render(self):
     """ Testing render on a small board """
     with open("test_inputs/test_render.json") as f:
         inp = json.load(f)
     result = lab.render(inp)
     expected = [[" ", " ", " ", " ", " ", " ", " ", " "],
                 [" ", " ", " ", " ", " ", "1", "1", "1"],
                 [" ", " ", " ", " ", "1", "2", "_", "_"],
                 ["1", "2", "1", "2", "2", "_", "_", "_"],
                 ["_", "_", "_", "_", "_", "_", "_", "_"],
                 ["_", "_", "_", "_", "_", "_", "_", "_"],
                 ["_", "_", "_", "_", "_", "_", "_", "_"],
                 ["_", "_", "_", "_", "_", "_", "_", "_"],
                 ["_", "_", "_", "_", "_", "_", "_", "_"],
                 ["_", "_", "_", "_", "_", "_", "_", "_"]]
     self.assertEqual(result, expected)
コード例 #4
0
ファイル: wrapper.py プロジェクト: jma100/MIT-6.009-lab_4
def ui_render(d):
    r = lab.render(d["game"], d["xray"])
    return r