-
-
Notifications
You must be signed in to change notification settings - Fork 45.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested functions can't be tested by doctest #10837
Comments
misclicked and accidentally closed the issue, sorry... |
Why not just write the code just |
Oh yeah my bad, I forgot that was a thing What I wanted to show with those screenshots was just that I really just that there is indeed doctests for Below is the relavant part of the code, if you want the whole file then here’s the link to it: https://github.com/nkstonks/Python/blob/master/maths/fibonacci.py
|
I don't know why but When I run the code. The error doesn't come in my computer. I am using the online python compiler (Interpreter) |
Yeah the program runs just fine, it's just that if you look at the output of it, towards the end of it it says this:
The thing with this is that it's not testing the tests in the But if I take the
notice how the If I run this, the program runs fine and the
So that's why I'm proposing to take the |
This comment was marked as spam.
This comment was marked as spam.
def fib_recursive(n: int) -> list[int]:
This corrected code properly implements memoization and stores the computed Fibonacci numbers in the memo list. It also eliminates the redundant computations in the original code, which makes it more efficient.
|
…cursive() for proper doctest coverage and improved code organization.
Feature description
#9943
So I was adding doctests to a nested function in fibonacci.py, however doctest doesn't seem to be testing that function.
The function in this case is fib_recursive_term(), that's nested inside fib_recursive, as seen below:
Note: the 5 doctests for fib_recursive_term() is what I added.
If I run the doctests, I get this output below.
As per the output below, 5 tests for fib_recursive() runs, but the 5 tests for fib_recursive_term() doesn't.
So I want to propose taking the fib_recursive_term() function out of the fib_recursive() function and have it defined above it, so doctests actually goes through it. Would there be any issues there?
The text was updated successfully, but these errors were encountered: