2011-04-26 23:04:28 +00:00
|
|
|
|
2011-05-02 13:39:58 +00:00
|
|
|
import pytest
|
|
|
|
from pokedex.tests import single_params
|
|
|
|
|
2011-04-27 13:00:50 +00:00
|
|
|
import sys
|
|
|
|
|
2011-04-27 11:30:11 +00:00
|
|
|
from pokedex.db import connect
|
2011-04-26 23:04:28 +00:00
|
|
|
from pokedex.util.movesets import main
|
|
|
|
|
2011-05-02 13:39:58 +00:00
|
|
|
result_map = {'OK': True, 'NO': False}
|
|
|
|
session = connect()
|
|
|
|
|
|
|
|
argstrings = u"""
|
2011-04-27 13:00:50 +00:00
|
|
|
NO muk
|
|
|
|
NO beedrill rage pursuit agility endeavor toxic
|
|
|
|
NO ditto psystrike aeroblast mist-ball judgment
|
|
|
|
OK metapod tackle harden
|
|
|
|
OK lugia aeroblast punishment dive snore
|
|
|
|
OK yanmega bug-bite bug-buzz tackle whirlwind
|
2011-04-27 19:50:14 +00:00
|
|
|
OK yanmega whirlwind
|
2011-04-27 13:00:50 +00:00
|
|
|
OK crobat brave-bird quick-attack gust zen-headbutt
|
|
|
|
OK bagon defense-curl fire-fang hydro-pump shadow-claw
|
|
|
|
OK volcarona endure toxic fly fire-blast
|
|
|
|
OK hippopotas curse revenge sleep-talk swallow
|
|
|
|
OK hippopotas curse revenge sleep-talk snore
|
|
|
|
OK smeargle bug-bite bug-buzz splash fire-blast
|
|
|
|
NO smeargle bug-bite chatter splash fire-blast
|
|
|
|
NO azurill muddy-water iron-tail scald mimic
|
|
|
|
OK salamence dragon-dance dragon-claw fire-blast earthquake -v platinum
|
|
|
|
OK crawdaunt brick-break rock-slide facade toxic -v platinum
|
|
|
|
NO cleffa tickle wish amnesia splash
|
|
|
|
OK tyrogue pursuit
|
|
|
|
NO happiny softboiled
|
|
|
|
NO mamoswine bite body-slam curse double-edge
|
|
|
|
OK shedinja swords-dance
|
|
|
|
NO shedinja swords-dance screech
|
2011-04-27 15:00:35 +00:00
|
|
|
OK shedinja baton-pass grudge
|
2011-04-27 13:00:50 +00:00
|
|
|
OK shedinja screech double-team fury-cutter x-scissor
|
|
|
|
OK raichu volt-tackle
|
|
|
|
OK raichu surf -v gold
|
|
|
|
OK pikachu volt-tackle thunderbolt bide
|
|
|
|
OK gyarados flail thrash iron-head outrage
|
|
|
|
OK drifblim memento gust thunderbolt pain-split
|
|
|
|
OK crobat nasty-plot brave-bird
|
|
|
|
NO crobat nasty-plot hypnosis
|
|
|
|
OK garchomp double-edge thrash outrage
|
|
|
|
OK nidoking counter disable amnesia head-smash
|
|
|
|
OK aggron stomp smellingsalt screech fire-punch
|
|
|
|
OK tyranitar dragon-dance outrage thunder-wave surf
|
|
|
|
NO butterfree morning-sun harden
|
|
|
|
OK pikachu reversal bide nasty-plot discharge
|
|
|
|
NO pikachu surf charge
|
|
|
|
NO blissey wish counter
|
|
|
|
NO clefairy copycat dynamicpunch
|
2011-04-27 19:50:14 +00:00
|
|
|
OK rotom overheat
|
|
|
|
OK rotom blizzard
|
|
|
|
NO rotom overheat blizzard
|
|
|
|
OK deoxys superpower amnesia spikes taunt
|
|
|
|
OK deoxys counter extremespeed spikes pursuit
|
|
|
|
OK pikachu reversal bide nasty-plot discharge
|
|
|
|
NO pikachu surf charge
|
|
|
|
OK pikachu volt-tackle encore headbutt grass-knot
|
2011-05-02 13:39:58 +00:00
|
|
|
#OK suicune extremespeed dig icy-wind bite
|
2011-08-30 11:05:45 +00:00
|
|
|
NO nidoran-m horn-drill head-smash -l 5 -v platinum --pomeg-glitch
|
2011-05-02 13:39:58 +00:00
|
|
|
""".strip().splitlines()
|
2011-04-27 01:58:15 +00:00
|
|
|
|
2011-05-02 13:39:58 +00:00
|
|
|
@single_params(*argstrings)
|
|
|
|
def test_moveset(argstring):
|
|
|
|
if argstring[0] == '#':
|
|
|
|
xfail = True
|
|
|
|
argstring = argstring[1:]
|
|
|
|
else:
|
|
|
|
xfail = False
|
|
|
|
args = argstring.strip().split() + ['-q']
|
|
|
|
try:
|
|
|
|
assert bool(main(args[1:], session=session)) == result_map[args[0]]
|
|
|
|
except AssertionError:
|
|
|
|
if xfail:
|
|
|
|
pytest.xfail()
|
|
|
|
raise
|
2011-04-27 01:58:15 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2011-05-02 13:39:58 +00:00
|
|
|
# XXX: Is there a profiler for py.test?
|
|
|
|
# Just use cProfile for now.
|
2011-04-27 01:58:15 +00:00
|
|
|
filename = 'movesets.profile'
|
|
|
|
print 'Profiling the moveset checker'
|
|
|
|
import cProfile
|
2011-04-27 13:00:50 +00:00
|
|
|
ok_fail = [0, 0]
|
2011-05-02 13:39:58 +00:00
|
|
|
def run_case(argv):
|
2011-04-27 13:00:50 +00:00
|
|
|
print argv, '...',
|
|
|
|
sys.stdout.flush()
|
|
|
|
try:
|
2011-05-02 13:39:58 +00:00
|
|
|
test_moveset(argv)
|
2011-04-27 13:00:50 +00:00
|
|
|
ok_fail[0] += 1
|
|
|
|
print 'ok'
|
2011-05-02 13:39:58 +00:00
|
|
|
except (AssertionError, pytest.xfail.Exception):
|
2011-04-27 13:00:50 +00:00
|
|
|
ok_fail[1] += 1
|
|
|
|
print 'FAIL'
|
2011-05-02 13:39:58 +00:00
|
|
|
cProfile.runctx("[(run_case(argv.strip())) for argv in argstrings]",
|
2011-04-27 01:58:15 +00:00
|
|
|
globals(), locals(), filename=filename)
|
2011-04-27 15:00:35 +00:00
|
|
|
if ok_fail[1]:
|
|
|
|
print '*** FAILED ***'
|
|
|
|
print "{0} tests: {1[0]} OK, {1[1]} failed".format(sum(ok_fail), ok_fail)
|
|
|
|
else:
|
|
|
|
print "{0} tests: OK".format(sum(ok_fail), ok_fail)
|
2011-04-27 01:58:15 +00:00
|
|
|
print 'Profile stats saved to', filename
|