Esempio n. 1
0
 def setUp(self):
     self.include_levels = ['Kids', 'Easy', 'Moderate']
     self.test_cases = [
         x for x in su.SAMPLE_PUZZLES if x['level'] in self.include_levels
     ]
     self.pt = pt.PuzzleTester(puzzle_class=su.SudokuPuzzle)
     self.pt.add_test_cases(self.test_cases)
Esempio n. 2
0
    def test_results(self):
        """Check test results"""
        solver = su.SudokuSolver()
        self.assertEqual(3, len(self.pt.get_test_results()))
        self.pt.run_tests(solver)
        self.assertEqual(4, len(self.pt.get_test_results()))
        self.assertEqual(1, len(self.pt.get_solver_labels()))

        results = self.pt.get_test_results()
        newpt = pt.PuzzleTester(puzzle_class=su.SudokuPuzzle)
        newpt.set_test_results(results)
        self.assertEqual(self.pt.get_test_results(), newpt.get_test_results())
Esempio n. 3
0
    def test_class_init_and_add_cases(self):
        """Test we can create class and add test cases"""
        self.assertTrue(isinstance(self.pt, pt.PuzzleTester))

        self.pt.add_test_cases(self.test_cases)
        self.assertEqual(3, self.pt.num_test_cases())

        # Add some bad cases
        self.assertRaises(ValueError, self.pt.add_test_cases, 'banana')
        self.assertRaises(ValueError, self.pt.add_test_cases,
                          ['banana', 'vodka'])

        # Add test cases without labels
        self.pt = pt.PuzzleTester(ls.LatinSquare)
        for tc in self.test_cases:
            del tc['label']
        self.pt.add_test_cases(self.test_cases)
        self.assertEqual(3, self.pt.num_test_cases())
Esempio n. 4
0
    def setUp(self):
        self.pt = pt.PuzzleTester(ls.LatinSquare)
        self.test_cases = []

        for i, puz in enumerate(TEST_PUZZLE_STRINGS):
            self.test_cases.append({'label': f"test {i}", 'puzzle': puz})
Esempio n. 5
0
 def test_from_file(self):
     """Can load test data from file"""
     tester = pt.PuzzleTester(ls.LatinSquare)
     tester.add_test_cases(pt.from_file("data/sudoku_9x9/hardest.txt"))
     self.assertEqual(13, tester.num_test_cases())