def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.sut = PasiekaFitness() self.rule = Rule(Symbol(hash('A')), Symbol(hash('B')), Symbol(hash('C'))) self.statistics_mock = create_autospec(GrammarStatistics)
class TestPasiekaFitness(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.sut = PasiekaFitness() self.rule = Rule(Symbol(hash('A')), Symbol(hash('B')), Symbol(hash('C'))) self.statistics_mock = create_autospec(GrammarStatistics) def test_fitness_should_be_calculated_properly(self): rule_info = PasiekaRuleInfo() rule_info.rule_usage = 4 left_side_info = PasiekaLeftSideInfo() left_side_info.left_side_usage = 5 self.statistics_mock.get_rule_statistics.return_value = rule_info, left_side_info assert_that(self.sut.calculate(self.statistics_mock, self.rule), is_(equal_to(4)))