本文整理汇总了Python中solver.Solver.norvig_algorithm方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.norvig_algorithm方法的具体用法?Python Solver.norvig_algorithm怎么用?Python Solver.norvig_algorithm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solver.Solver
的用法示例。
在下文中一共展示了Solver.norvig_algorithm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestSolver
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import norvig_algorithm [as 别名]
class TestSolver(unittest.TestCase):
def setUp(self):
self.solver_txt = Solver("juego.txt")
self.solver_csv = Solver("juego.csv")
self.solver_invalidtxt = Solver("juego1.txt")
self.solver_invalidcsv = Solver("juego1.csv")
self.solver_other = Solver("juego.png")
self.resultpuzzle = '483921657967345821251876493548132976729564138136798245372689514814253769695417382'
### ******* Unittest for solver class *************
def test_if_solver_resolves_a_sudoku_from_a_TXT_file_using_norvig_algorithm(self):
expected = self.resultpuzzle
self.assertEqual(expected,self.solver_txt.norvig_algorithm())
def test_if_solver_handle_invalid_TXT_file_using_norvig_algorithm(self):
expected = "Please insert the correct data and size in the txt file"
self.assertEqual(expected,self.solver_invalidtxt.norvig_algorithm())
def test_if_solver_resolves_a_sudoku_from_a_CSV_file_using_norvig_algorithm(self):
expected = self.resultpuzzle
self.assertEqual(expected,self.solver_csv.norvig_algorithm())
def test_if_solver_handle_invalid_CSV_file_using_norvig_algorithm(self):
expected = "Please insert the correct data and size in the csv file"
self.assertEqual(expected,self.solver_invalidcsv.norvig_algorithm())
def test_if_solver_returns_a_friendly_message_when_invalid_file_is_inserted(self):
expected = 'invalid extension'
self.assertEqual(expected,self.solver_other.norvig_algorithm())
def test_if_solution_is_stored_in_a_txt_file(self):
f1 = open("presolution.txt",'r')
expected = f1.read()
f1.close()
self.assertEqual(expected,self.solver_txt.store_solution_in_txt_file())