Fix test_media.py.

- Add --media-root option (was half-supported already, but not accepted
  on the command line).

- Don't test for Colosseum and XD graphics, since we have none.

- Acknowledge *-beta sprites.
This commit is contained in:
Andrew Ekstedt 2012-03-15 17:46:25 -07:00
parent 61ed3c4ccb
commit 14d9b6ead7
2 changed files with 15 additions and 1 deletions

View file

@ -13,6 +13,11 @@ import re
from pokedex.db import tables, connect
from pokedex.util import media
def pytest_addoption(parser):
group = parser.getgroup("pokedex")
group.addoption("--media-root", dest="media_root", action="store", default=None,
help="path to pokedex-media")
def pytest_funcarg__root(request):
root = request.config.option.media_root
if not root:
@ -119,6 +124,10 @@ def test_get_everything(root, pytestconfig):
versions = list(session.query(tables.Version).all())
versions.append('red-green')
# We don't have any graphics for Colosseum or XD
versions.remove(session.query(tables.Version).filter_by(identifier=u'colosseum').one())
versions.remove(session.query(tables.Version).filter_by(identifier=u'xd').one())
black = session.query(tables.Version).filter_by(identifier=u'black').one()
filenames = get_all_filenames(root)
@ -243,6 +252,8 @@ def test_get_everything(root, pytestconfig):
for filename in filenames:
if filename.startswith(exceptions):
unaccessed_filenames.remove(filename)
if filename.endswith('-beta.png'):
unaccessed_filenames.remove(filename)
if unaccessed_filenames:
print 'Unaccessed files:'

View file

@ -193,7 +193,10 @@ class _BasePokemonMedia(BaseMedia):
version_group = version.version_group
version_dir = '-'.join(
v.identifier for v in version_group.versions)
try:
generation, info = self._pokemon_sprite_info[version_dir]
except KeyError:
raise ValueError('Version directory %s not found', version_dir)
if generation < self.introduced_in:
raise ValueError("Pokemon %s didn't exist in %s" % (
self.species_id, version_dir))