def test_unown(self, game_name): game = pkmn.string_to_game(game_name) unown_entry = pkmn.database.pokemon_entry(pkmn.species.UNOWN, game, "") unown = None for form in unown_entry.forms: unown = pkmn.pokemon(pkmn.species.UNOWN, game, form, 5) self.assertEqual(unown.form, form) # Make sure personality is properly set. form_from_personality = pkmn.calculations.gen3_unown_form( unown.personality) self.assertEqual(unown.form, form_from_personality) self.assertTrue(os.path.exists(unown.icon_filepath)) self.assertTrue(os.path.exists(unown.sprite_filepath)) # Make sure setting the form properly changes the IVs. for form in unown_entry.forms: unown.form = form self.assertEqual(unown.form, form) # Make sure personality is properly set. form_from_personality = pkmn.calculations.gen3_unown_form( unown.personality) self.assertEqual(unown.form, form_from_personality) self.assertTrue(os.path.exists(unown.icon_filepath)) self.assertTrue(os.path.exists(unown.sprite_filepath)) # Make sure setting the personality properly sets the form. unown.personality = 0x4C07DE71 self.assertEqual(unown.form, "B")
def test_pokedex(self, game_name): game = pkmn.string_to_game(game_name) generation = pkmntest.GAME_TO_GENERATION[game] pokedex = pkmn.pokedex(game) # Test initial values. self.assertEqual(pokedex.num_seen, 0) self.assertEqual(len(pokedex.all_seen), 0) self.assertEqual(pokedex.num_caught, 0) self.assertEqual(len(pokedex.all_caught), 0) # Set random Pokemon to be seen and caught. all_pokemon = pkmn.database.lists.get_pokemon_list(generation, True) num_seen = random.randint(0, len(all_pokemon)) num_caught = random.randint(0, len(all_pokemon)) all_seen_nums = [] while len(all_seen_nums) < num_seen: index = random.randint(0, len(all_pokemon) - 1) if index not in all_seen_nums: all_seen_nums += [index] species = all_pokemon[index] pokedex.seen_pokemon_map[species] = True self.assertTrue(pokedex.seen_pokemon_map[species]) self.assertTrue(species in pokedex.all_seen) self.assertEqual(pokedex.num_seen, len(all_seen_nums)) self.assertEqual(len(pokedex.all_seen), len(all_seen_nums)) all_caught_nums = [] while len(all_caught_nums) < num_caught: index = random.randint(0, len(all_pokemon) - 1) if index not in all_caught_nums: all_caught_nums += [index] species = all_pokemon[index] pokedex.caught_pokemon_map[species] = True self.assertTrue(pokedex.caught_pokemon_map[species]) self.assertTrue(species in pokedex.all_caught) self.assertEqual(pokedex.num_caught, len(all_caught_nums)) self.assertEqual(len(pokedex.all_caught), len(all_caught_nums)) # Remove all entries. for species in pokedex.all_seen: pokedex.seen_pokemon_map[species] = False self.assertFalse(pokedex.seen_pokemon_map[species]) self.assertEqual(pokedex.num_seen, 0) self.assertEqual(len(pokedex.all_seen), 0) for species in pokedex.all_caught: pokedex.caught_pokemon_map[species] = False self.assertFalse(pokedex.caught_pokemon_map[species]) self.assertEqual(pokedex.num_caught, 0) self.assertEqual(len(pokedex.all_caught), 0)
def test_forms(self, game_name): game = pkmn.string_to_game(game_name) generation = GAME_TO_GENERATION[game] if generation >= 1: self.gen1_forms_test(game) if generation >= 2: self.gen2_forms_test(game) if generation >= 3: self.gen3_forms_test(game)
def test_unown(self, game_name): game = pkmn.string_to_game(game_name) unown_entry = pkmn.database.pokemon_entry(pkmn.species.UNOWN, game, "") unown = None for form in unown_entry.forms: unown = pkmn.pokemon(pkmn.species.UNOWN, game, form, 5) self.assertEqual(unown.form, form) # Make sure IVs are properly set. form_from_IVs = pkmn.calculations.gen2_unown_form( unown.IVs[pkmn.pokemon_stat.ATTACK], unown.IVs[pkmn.pokemon_stat.DEFENSE], unown.IVs[pkmn.pokemon_stat.SPEED], unown.IVs[pkmn.pokemon_stat.SPECIAL] ) self.assertEqual(unown.form, form_from_IVs) self.assertTrue(os.path.exists(unown.icon_filepath)) self.assertTrue(os.path.exists(unown.sprite_filepath)) # Make sure setting the form properly changes the IVs. for form in unown_entry.forms: unown.form = form self.assertEqual(unown.form, form) # Make sure IVs are properly set. form_from_IVs = pkmn.calculations.gen2_unown_form( unown.IVs[pkmn.pokemon_stat.ATTACK], unown.IVs[pkmn.pokemon_stat.DEFENSE], unown.IVs[pkmn.pokemon_stat.SPEED], unown.IVs[pkmn.pokemon_stat.SPECIAL] ) self.assertEqual(unown.form, form_from_IVs) self.assertTrue(os.path.exists(unown.icon_filepath)) self.assertTrue(os.path.exists(unown.sprite_filepath)) # Make sure setting IVs properly changes the form. unown.IVs[pkmn.pokemon_stat.ATTACK] = 10; unown.IVs[pkmn.pokemon_stat.DEFENSE] = 9; unown.IVs[pkmn.pokemon_stat.SPEED] = 1; unown.IVs[pkmn.pokemon_stat.SPECIAL] = 14; self.assertEquals(unown.form, "G");
def test_unown(self, game_name): game = pkmn.string_to_game(game_name) unown_entry = pkmn.database.pokemon_entry(pkmn.species.UNOWN, game, "") unown = None for form in unown_entry.forms: unown = pkmn.pokemon(pkmn.species.UNOWN, game, form, 5) self.assertEqual(unown.form, form) # Make sure IVs are properly set. form_from_IVs = pkmn.calculations.gen2_unown_form( unown.IVs[pkmn.pokemon_stat.ATTACK], unown.IVs[pkmn.pokemon_stat.DEFENSE], unown.IVs[pkmn.pokemon_stat.SPEED], unown.IVs[pkmn.pokemon_stat.SPECIAL]) self.assertEqual(unown.form, form_from_IVs) self.assertTrue(os.path.exists(unown.icon_filepath)) self.assertTrue(os.path.exists(unown.sprite_filepath)) # Make sure setting the form properly changes the IVs. for form in unown_entry.forms: unown.form = form self.assertEqual(unown.form, form) # Make sure IVs are properly set. form_from_IVs = pkmn.calculations.gen2_unown_form( unown.IVs[pkmn.pokemon_stat.ATTACK], unown.IVs[pkmn.pokemon_stat.DEFENSE], unown.IVs[pkmn.pokemon_stat.SPEED], unown.IVs[pkmn.pokemon_stat.SPECIAL]) self.assertEqual(unown.form, form_from_IVs) self.assertTrue(os.path.exists(unown.icon_filepath)) self.assertTrue(os.path.exists(unown.sprite_filepath)) # Make sure setting IVs properly changes the form. unown.IVs[pkmn.pokemon_stat.ATTACK] = 10 unown.IVs[pkmn.pokemon_stat.DEFENSE] = 9 unown.IVs[pkmn.pokemon_stat.SPEED] = 1 unown.IVs[pkmn.pokemon_stat.SPECIAL] = 14 self.assertEquals(unown.form, "G")
def test_gender(self, game_name): game = pkmn.string_to_game(game_name) # Single-gender nidorina = pkmn.pokemon(pkmn.species.NIDORINA, game, "", 50) self.assertEqual(nidorina.gender, pkmn.gender.FEMALE) nidorina.gender = pkmn.gender.FEMALE with self.assertRaises(ValueError): nidorina.gender = pkmn.gender.MALE with self.assertRaises(ValueError): nidorina.gender = pkmn.gender.GENDERLESS nidorino = pkmn.pokemon(pkmn.species.NIDORINO, game, "", 50) self.assertEqual(nidorino.gender, pkmn.gender.MALE) nidorino.gender = pkmn.gender.MALE with self.assertRaises(ValueError): nidorino.gender = pkmn.gender.FEMALE with self.assertRaises(ValueError): nidorino.gender = pkmn.gender.GENDERLESS magnemite = pkmn.pokemon(pkmn.species.MAGNEMITE, game, "", 50) self.assertEqual(magnemite.gender, pkmn.gender.GENDERLESS) magnemite.gender = pkmn.gender.GENDERLESS with self.assertRaises(ValueError): magnemite.gender = pkmn.gender.MALE with self.assertRaises(ValueError): magnemite.gender = pkmn.gender.FEMALE mixed_pokemon = [ pkmn.species.CHARMANDER, # 87.5% male pkmn.species.GROWLITHE, # 75% male pkmn.species.PIDGEY, # 50% male pkmn.species.VULPIX # 25% male ] for species in mixed_pokemon: pokemon = pkmn.pokemon(species, game, "", 50) pokemon.gender = pkmn.gender.FEMALE self.assertEqual(pokemon.gender, pkmn.gender.FEMALE) pokemon.gender = pkmn.gender.MALE self.assertEqual(pokemon.gender, pkmn.gender.MALE) with self.assertRaises(ValueError): pokemon.gender = pkmn.gender.GENDERLESS
def test_game_list(self): # Make sure trying to create an invalid list results in an error with self.assertRaises(IndexError): pkmn.database.lists.get_game_list(7, False) with self.assertRaises(IndexError): pkmn.database.lists.get_game_name_list(7, False) game_list = pkmn.database.lists.get_game_list(6, True) self.assertEqual(26, len(game_list)) self.assertEqual(pkmn.game.RED, game_list[0]) self.assertEqual(pkmn.game.ALPHA_SAPPHIRE, game_list[-1]) game_name_list = pkmn.database.lists.get_game_name_list(6, True) self.assertEqual(26, len(game_name_list)) self.assertEqual("Red", game_name_list[0]) self.assertEqual("Alpha Sapphire", game_name_list[-1]) for index, game_name in enumerate(game_name_list): self.assertEqual(game_list[index], pkmn.string_to_game(game_name))
def test_pokemon(self, species_name, game_name): species = pkmn.string_to_species(species_name) game = pkmn.string_to_game(game_name) pokemon = pkmn.pokemon(species, game, "", 30) test_params = None valid_moves = [ pkmn.move.SWALLOW, pkmn.move.FLAMETHROWER, pkmn.move.RETURN, pkmn.move.FIRE_BLAST ] valid_games = [ pkmn.game.RUBY, pkmn.game.SAPPHIRE, pkmn.game.EMERALD, pkmn.game.FIRERED, pkmn.game.LEAFGREEN, pkmn.game.COLOSSEUM, pkmn.game.XD ] if game in [pkmn.game.COLOSSEUM, pkmn.game.XD]: test_params = pokemon_test_base.pokemon_test_params( pkmn.ball.GREAT_BALL, [pkmn.ball.FRIEND_BALL, pkmn.ball.HEAL_BALL], pkmn.item.RAZZ_BERRY, [pkmn.item.BERRY, pkmn.item.MACH_BIKE], "Distant land", ["Phenac Story", "Orre Colosseum"], ["New Bark Town", "Twinleaf Town"], valid_moves, [pkmn.move.ROOST, pkmn.move.FLAME_BURST], valid_games, [pkmn.game.GOLD, pkmn.game.HEARTGOLD]) else: test_params = pokemon_test_base.pokemon_test_params( pkmn.ball.GREAT_BALL, [pkmn.ball.FRIEND_BALL, pkmn.ball.HEAL_BALL], pkmn.item.RAZZ_BERRY, [pkmn.item.BERRY, pkmn.item.MACH_BIKE], "Fateful encounter", ["Petalburg Woods", "Viridian Forest"], ["New Bark Town", "Twinleaf Town"], valid_moves, [pkmn.move.SHADOW_SKY, pkmn.move.ROOST], valid_games, [pkmn.game.GOLD, pkmn.game.HEARTGOLD]) self.common_test(pokemon, test_params)
def test_pokemon_box(self, game_name): box = pkmn.pokemon_box(pkmn.string_to_game(game_name)) self.__test_empty_pokemon_box(box) self.__test_box_name(box) self.__test_setting_pokemon(box)
def test_saving_and_loading_3gpkm(self, game_name): self._test_saving_and_loading( pkmn.string_to_game(game_name), "3gpkm" )
def test_pokemon_party(self, game_name): party = pkmn.pokemon_party(pkmn.string_to_game(game_name)) self.__test_empty_pokemon_party(party) self.__test_setting_pokemon(party)
def test_pokemon_pc(self, game_name): pc = pkmn.pokemon_pc(pkmn.string_to_game(game_name)) self.__test_empty_pokemon_pc(pc) self.__test_box_names(pc) self.__test_setting_pokemon_in_boxes(pc)
def test_saving_and_loading_3gpkm(self, game_name): self._test_saving_and_loading(pkmn.string_to_game(game_name), "3gpkm")
def test_saving_and_loading_pk3(self, game_name): self._test_saving_and_loading( pkmn.string_to_game(game_name), "pk3" )
def test_saving_and_loading_pk3(self, game_name): self._test_saving_and_loading(pkmn.string_to_game(game_name), "pk3")