Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ python:

install:
- pip install coverage
- pip install --upgrade pytest pytest-benchmark

script:
- |
if [[ $(bc <<< "$TRAVIS_PYTHON_VERSION >= 3.3") -eq 1 ]]; then
nosetests --with-doctest
py.test --doctest-modules multipledispatch
else
nosetests --with-doctest -I '.*_3only.py$'
py.test --doctest-modules --ignore=multipledispatch/tests/test_dispatcher_3only.py multipledispatch
fi

after_success:
Expand Down
15 changes: 14 additions & 1 deletion multipledispatch/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def f(x):
assert raises(NotImplementedError, lambda: f('hello'))


def test_multipledispatch():
def test_multipledispatch(benchmark):
@dispatch(int, int)
def f(x, y):
return x + y
Expand Down Expand Up @@ -203,3 +203,16 @@ def f(x, y):
assert foo.f(A(), A()) == 1
assert foo.f(A(), C()) == 2
assert foo.f(C(), C()) == 2


# Hacky method to get benchmnarks namespaced
class TestBenchMark(object):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically a holder to stick generated tests into, with decent names so that pytest can discover them appropriately.

sadly pytest-benchmark doesn't just provide a decorator.

pass


for k, v in list(locals().items()):
if callable(v) and (k.startswith('test_')):

def bench(self, benchmark):
benchmark(v)
setattr(TestBenchMark, '{}'.format(k), bench)