class getMod(unittest.TestCase): """ Test cases of getMod """ def setUp(self): """ Build the Pkmn and Delegate for the test """ self.user = BuildPokemonBattleWrapper() self.target = BuildPokemonBattleWrapper() self.delegate = HitDelegate(None, 100) def accuracyMods(self): """ Test that accuracy mods correctly change the accuracy """ length = len(HitDelegate.accMods)/2 for i in range(-length, length+1): self.user.statMods["ACC"] = i mod = self.delegate.getMod(self.user, self.target) assert mod == HitDelegate.accMods[i], "Mod should be acc mod" def evasionMods(self): """ Test that evasion mods correctly change the accuracy """ length = len(HitDelegate.accMods)/2 for i in range(-1*length, length+1): self.target.statMods["EVAS"] = i mod = self.delegate.getMod(self.user, self.target) assert mod == HitDelegate.accMods[-i], "Mod should be evas mod" def balanced(self): """ Test that evasion and accuracy mods balance each other out """ length = len(HitDelegate.accMods)/2 for i in range(-1*length, length+1): self.user.statMods["ACC"] = i self.target.statMods["EVAS"] = i mod = self.delegate.getMod(self.user, self.target) assert mod == HitDelegate.accMods[0], "Mod should be 1 when evas and acc are the same"