Skip to content
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

Add unit test to fizzbuzzo3 #8

Merged
merged 5 commits into from
Mar 22, 2024
Merged

Add unit test to fizzbuzzo3 #8

merged 5 commits into from
Mar 22, 2024

Conversation

MusicalNinjaDad
Copy link
Owner

No description provided.

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a262d0e) to head (034d2d1).

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #8   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           12        12           
  Branches         1         1           
=========================================
  Hits            12        12           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @MusicalNinjaDad - I've reviewed your changes and they look great!

General suggestions:

  • Consider expanding the test coverage to include various input scenarios for the fizzbuzz function, ensuring comprehensive validation of its behavior.
  • Implement more descriptive error handling in tests to improve the clarity and usefulness of test failure messages.
  • Include tests that validate the Python environment setup to prevent false negatives caused by configuration or environment issues.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 3 issues found
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +29 to +32
let fizzbuzz = fizzbuzzo3.getattr("fizzbuzz").expect("Failed to get fizzbuzz function");
let result = fizzbuzz.call((1i32,), None).expect("Failed to call fizzbuzz");
let expected_result = "1";
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): Consider handling potential exceptions more gracefully.

Using expect in tests for library imports and function calls can be abrupt. It might be more informative to handle potential exceptions more gracefully to provide clearer feedback on what exactly failed.

let fizzbuzz = fizzbuzzo3.getattr("fizzbuzz").expect("Failed to get fizzbuzz function");
let result = fizzbuzz.call((1i32,), None).expect("Failed to call fizzbuzz");
let expected_result = "1";
assert_eq!(result.extract::<String>().unwrap(), expected_result);
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): Use of unwrap in test assertions could be replaced with more descriptive error handling.

While unwrap is convenient, in a test scenario, it might be more beneficial to use match or if let constructs to provide more context-specific error messages upon failures.

fizzbuzzo3/src/lib.rs Show resolved Hide resolved
// use pyo3::prelude::*;

#[test]
fn test_fizzbuzz() {
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Add error handling test cases for fizzbuzz function.

It's important to test how the fizzbuzz function behaves under error conditions or with invalid inputs. Consider adding tests that pass invalid arguments to the fizzbuzz function to ensure it fails gracefully.

fizzbuzzo3/src/lib.rs Show resolved Hide resolved
@MusicalNinjaDad MusicalNinjaDad merged commit eca1e82 into main Mar 22, 2024
10 checks passed
@MusicalNinjaDad MusicalNinjaDad deleted the fizzbuzzo3_tests branch March 22, 2024 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant