def setUp(self): self.b = Block() Block.instances = []
(3, 1), (3, 2), (3, 3), (3, 4)], "still too much points": [(63, 30), (63, 31), (63, 32), (63, 33)], "point missing: 9": [(1, 1), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)], "point missing: 6": [(1, 0), (1, 1), (2, 0), (3, 0), (3, 1)], "points not aligned": [(1, 1), (1, 2), (1, 3), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3)], } def setUp(self): self.b = Block() Block.instances = [] def _generate_blocks(self, case, num=100): """Generate some blocks for testing block sizes""" blocks = [Block() for i in range(num)] for block in blocks: block.points = self.good_cases[case][0] return blocks def test_determine_block_size(self): """Test if correct size is determined based on passed points""" with self.subTest("initial value"): self.assertEqual(Block.size, 3) with self.subTest("all blocks has 9 points"): blocks = self._generate_blocks(9, 100) Block.determine_block_size() self.assertEqual(Block.size, 3) del blocks