Skip to content

Commit

Permalink
Integrate pytest-benchmark, add selector and full_game tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnamespace committed May 6, 2016
1 parent 25768de commit ddba623
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
hearthstone
pytest
pytest-benchmark
24 changes: 24 additions & 0 deletions tests/test_micro_bench.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit ddba623

Please sign in to comment.