本文整理汇总了Python中term2048.game.Game.store方法的典型用法代码示例。如果您正苦于以下问题:Python Game.store方法的具体用法?Python Game.store怎么用?Python Game.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类term2048.game.Game
的用法示例。
在下文中一共展示了Game.store方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_store_non_empty_file
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
def test_store_non_empty_file(self):
store = NamedTemporaryFile(delete=False)
store.close()
g = Game(scores_file=None, store_file=store.name)
self.assertTrue(g.store())
self.assertFileIsNotEmpty(store.name)
remove(store.name)
示例2: test_store_fail_return_false
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
def test_store_fail_return_false(self):
store = NamedTemporaryFile(delete=False)
store.close()
os.chmod(store.name, 0) # no rights at all
g = Game(scores_file=None, store_file=store.name)
self.assertFalse(g.store())
os.chmod(store.name, 0o200) # give me writing rights back
remove(store.name)
示例3: test_start_game_no_resume
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
def test_start_game_no_resume(self):
g1 = Game(scores_file=None)
g1.board.setCell(0, 0, 16)
self.assertTrue(g1.store())
sys.argv = ['term2048']
g2 = ui.start_game(debug=True)
self.assertIn(g2.board.getCell(0, 0), [0, 2, 4])
示例4: test_store_restore_empty_game
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
def test_store_restore_empty_game(self):
store = NamedTemporaryFile(delete=False)
store.close()
g1 = Game(scores_file=None, store_file=store.name)
self.assertTrue(g1.store())
g2 = Game(scores_file=None, store_file=store.name)
g2.board.setCell(0, 0, 16)
self.assertTrue(g2.restore())
self.assertIn(g2.board.getCell(0, 0), [0, 2, 4])
remove(store.name)
示例5: test_start_game_resume
# 需要导入模块: from term2048.game import Game [as 别名]
# 或者: from term2048.game.Game import store [as 别名]
def test_start_game_resume(self):
cellvalue = 2
g1 = Game(scores_file=None)
g1.board.setCell(0, 0, cellvalue)
g1.score = 42
self.assertTrue(g1.store())
sys.argv = ['term2048', '--resume']
g2 = ui.start_game(debug=True)
self.assertEqual(cellvalue, g2.board.getCell(0, 0))
self.assertEqual(g1.score, g2.score)