Skip to content

Commit

Permalink
Remove pytest-benchmark dependency
Browse files Browse the repository at this point in the history
skip benchmarks if not installed (e.g. on Travis)
  • Loading branch information
jnnk committed Sep 27, 2015
1 parent d630ea6 commit 8e22b14
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def run_tests(self):

test_requirements = [
'pytest',
'pytest-benchmark'
]

setup(
Expand Down
22 changes: 17 additions & 5 deletions tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
from rlp.exceptions import DecodingError, DeserializationError


try:
import pytest_benchmark
except ImportError:
do_benchmark = False
else:
do_benchmark = True


# speed up setup in case tests aren't run anyway
if do_benchmark:
SIZE = int(1e6)
else:
SIZE = 1


class Message(rlp.Serializable):

fields = [
Expand All @@ -16,9 +31,6 @@ class Message(rlp.Serializable):
]


SIZE = int(1e6)


def lazy_test_factory(s, valid):
@pytest.mark.benchmark(group='lazy')
def f(benchmark):
Expand Down Expand Up @@ -77,8 +89,8 @@ def generate_test_functions():

current_module = sys.modules[__name__]
for rlp_string, valid, name in zip(rlp_strings, valids, names):
f_eager = eager_test_factory(rlp_string, valid)
f_lazy = lazy_test_factory(rlp_string, valid)
f_eager = pytest.mark.skipif('not do_benchmark')(eager_test_factory(rlp_string, valid))
f_lazy = pytest.mark.skipif('not do_benchmark')(lazy_test_factory(rlp_string, valid))
setattr(current_module, 'test_eager_' + name, f_eager)
setattr(current_module, 'test_lazy_' + name, f_lazy)

Expand Down

0 comments on commit 8e22b14

Please sign in to comment.