diff options
| author | Munyoki Kilyungi (aider) | 2025-02-26 17:36:30 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-03-04 15:48:10 +0300 |
| commit | 6a76e302f11c0a0aa0bc0ac8487ad250f8afb9bb (patch) | |
| tree | 3856af38567d39c30e56182536e0bb56e0afec03 /tests/unit/api/test_rqtl2.py | |
| parent | 9bad745abd94fd0eeb0b0dc6aba0d6a74db33f81 (diff) | |
| download | genenetwork3-6a76e302f11c0a0aa0bc0ac8487ad250f8afb9bb.tar.gz | |
docs: Add module and function docstrings for unit tests of fibonacci function
Diffstat (limited to 'tests/unit/api/test_rqtl2.py')
| -rw-r--r-- | tests/unit/api/test_rqtl2.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/api/test_rqtl2.py b/tests/unit/api/test_rqtl2.py index fbd0d25..a5c6516 100644 --- a/tests/unit/api/test_rqtl2.py +++ b/tests/unit/api/test_rqtl2.py @@ -1,28 +1,62 @@ +""" +Unit tests for the `fibonacci` function in the `gn3.api.rqtl2` module. + +This module contains a series of test cases to verify the correctness and robustness +of the Fibonacci number calculation function. It checks for valid inputs, boundary +conditions, and error handling to ensure the function behaves as expected under +various scenarios. +""" + import pytest from gn3.api.rqtl2 import fibonacci + def test_fibonacci_zero(): + """ + Test that the fibonacci function returns 0 when the input is 0. + """ assert fibonacci(0) == 0 + def test_fibonacci_one(): + """ + Test that the fibonacci function returns 1 when the input is 1. + """ assert fibonacci(1) == 1 + def test_fibonacci_ten(): + """ + Test that the fibonacci function returns 55 when the input is 10. + """ assert fibonacci(10) == 55 + def test_fibonacci_negative(): + """ + Test that the fibonacci function raises a ValueError when the input is negative. + """ with pytest.raises(ValueError) as excinfo: fibonacci(-1) assert "non-negative integer" in str(excinfo.value) + def test_fibonacci_non_integer(): + """ + Test that the fibonacci function raises a ValueError when the input is not an integer. + """ with pytest.raises(ValueError) as excinfo: fibonacci(5.5) assert "non-negative integer" in str(excinfo.value) + def test_fibonacci_large(): + """ + Test that the fibonacci function returns the correct value for a larger input (20). + """ assert fibonacci(20) == 6765 + @pytest.mark.parametrize("n, expected", [ (2, 1), (3, 2), @@ -32,4 +66,11 @@ def test_fibonacci_large(): (7, 13), ]) def test_fibonacci_multiple(n, expected): + """ + Test multiple cases of the fibonacci function using parameterization. + + Args: + n (int): The position in the Fibonacci sequence. + expected (int): The expected Fibonacci number at position `n`. + """ assert fibonacci(n) == expected |
