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 7, 2016
1 parent 25768de commit 2fc7933
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ cache:
directories:
- $HOME/.pip-cache/
- $HOME/virtualenv/python3.5
script:
# Travis will automatically detect requirements.txt and run pip install
install:
- pip install -r requirements.txt
- pip install pytest-benchmark
- ./setup.py install
script:
- py.test
- py.test tests/test_micro_bench.py
notifications:
email:
on_failure: always
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --ignore=tests/test_micro_bench.py --ignore=test_micro_bench.py
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 2fc7933

Please sign in to comment.