From aeed472393dd3dae20ebf78bbe0d13e352816643 Mon Sep 17 00:00:00 2001 From: smallnamespace Date: Fri, 6 May 2016 14:19:11 -0700 Subject: [PATCH] Integrate pytest-benchmark, add selector and full_game tests. Closes #314 --- .travis.yml | 7 +++++-- tests/benchmarks.py | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/benchmarks.py diff --git a/.travis.yml b/.travis.yml index 68f714a13..27455c4c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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/benchmarks.py notifications: email: on_failure: always diff --git a/tests/benchmarks.py b/tests/benchmarks.py new file mode 100644 index 000000000..05da33c55 --- /dev/null +++ b/tests/benchmarks.py @@ -0,0 +1,25 @@ +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): + random.seed(1857) + benchmark(test_full_game)