-
Notifications
You must be signed in to change notification settings - Fork 25
Replace slides on unittest by slides on pytest #16
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
Conversation
…ering into development
…ering into development
Have been replaced by slides on pytest
Reviewer's Guide by SourceryThis pull request replaces the unit test implementation with pytest. It also introduces custom markers and parameterization to the tests. Sequence diagram for parameterized test executionsequenceDiagram
participant P as Pytest Runner
participant T as Test Function
participant F as Fibonacci Function
loop For each test parameter
P->>T: Run test with parameter
T->>F: Call fib(n)
F-->>T: Return result
T-->>P: Assert result matches expected
end
Class diagram for Fibonacci implementation with test structureclassDiagram
class fibonacci {
+fib(n: int): int
}
class test_fib {
+test_negative_input()
+test_base_cases()
+test_recursive_case()
}
note for test_fib "Tests can be marked with @pytest.mark.slow"
test_fib ..> fibonacci : tests
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @gjbex - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| def fib(n): | ||
| if n < 0: | ||
| raise ValueError('fac argument must be positive') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (typo): Error message refers to 'fac argument' but this is a Fibonacci function
This appears to be a copy-paste error. Consider changing to 'fibonacci argument' or simply 'n' for clarity.
| raise ValueError('fac argument must be positive') | |
| raise ValueError('fibonacci argument must be positive') |
| if __name__ == '__main__': | ||
| from argparse import ArgumentParser | ||
| arg_parser = ArgumentParser(description='compute fibonacci numbers') | ||
| arg_parser.add_argument('n', type=int, default=5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Default value won't work for positional argument
The default parameter has no effect on positional arguments. Consider using an optional argument (--n) if a default value is needed.
| # Typing | ||
|
|
||
| Python 3.5 introducd optional type annotation for functions, and that | ||
| Python 3.5 introduced optional type annotation for functions, and that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (typo): Typo: "introducd" should be "introduced".
Summary by Sourcery
Introduce examples for using custom markers and parameterized tests with pytest.
Tests: