diff --git a/.travis.yml b/.travis.yml index 68f714a13..9a9aff7a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ cache: script: # Travis will automatically detect requirements.txt and run pip install - ./setup.py install - - py.test + - py.test --benchmark-max-time=0.5 notifications: email: on_failure: always diff --git a/requirements.txt b/requirements.txt index ba1e7f844..35a8bb02c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ hearthstone pytest +pytest-benchmark diff --git a/tests/test_micro_bench.py b/tests/test_micro_bench.py new file mode 100644 index 000000000..87ded7090 --- /dev/null +++ b/tests/test_micro_bench.py @@ -0,0 +1,24 @@ +from full_game import test_full_game +from utils import * + + +def run_selector(game, alex): + selector = PIRATE | DRAGON + MINION + assert len(selector.eval(game.player1.hand, game.player1)) >= 1 + + selector = IN_HAND + DRAGON + FRIENDLY + targets = selector.eval(game, game.player1) + assert len(targets) == 1 + assert targets[0] == alex + + +def test_selectors(benchmark): + game = prepare_game() + game.player1.discard_hand() + alex = game.player1.give("EX1_561") + + benchmark(run_selector, game, alex) + + +def test_fullgame(benchmark): + benchmark(test_full_game)