Skip to content

Instantly share code, notes, and snippets.

@okken
Created April 22, 2018 15:13
Show Gist options
  • Save okken/373fb7ca1f4e061c1effbf3a3d385c84 to your computer and use it in GitHub Desktop.
Save okken/373fb7ca1f4e061c1effbf3a3d385c84 to your computer and use it in GitHub Desktop.
alternate test for fibonacci
import pytest
from main import fibonacci
@pytest.mark.parametrize('n, expected',
enumerate([1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]))
def test_returns_correct_fibonacci_number(n, expected):
assert expected == fibonacci(n)
def test_raise_value_error_on_negative_input():
with pytest.raises(ValueError):
fibonacci(-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment