-
Notifications
You must be signed in to change notification settings - Fork 0
Add Tests for PR#23 #30
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
base: rohitvinnakota-codecov-patch-21
Are you sure you want to change the base?
Add Tests for PR#23 #30
Conversation
|
On it! We are reviewing the PR and will provide feedback shortly. |
| def test_add2(): | ||
| # Test that add2 function raises NameError due to undefined variable 'z' | ||
| with pytest.raises(NameError, match="name 'z' is not defined"): | ||
| Calculator.add2(1, 2) | ||
| Calculator.add2(0, 0) |
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.
The test is attempting to call Calculator.add2(), but this method does not exist in the Calculator class. This will result in an AttributeError: type object 'Calculator' has no attribute 'add2' instead of the expected NameError. The test should either be updated to test an existing method that contains an undefined variable, or the corresponding add2 method should be implemented in the Calculator class first.
| def test_add2(): | |
| # Test that add2 function raises NameError due to undefined variable 'z' | |
| with pytest.raises(NameError, match="name 'z' is not defined"): | |
| Calculator.add2(1, 2) | |
| Calculator.add2(0, 0) | |
| # First implement the add2 method in Calculator class, or update this test to use an existing method | |
| # Example if add2 method exists: | |
| # def test_add2(): | |
| # with pytest.raises(NameError, match="name 'z' is not defined"): | |
| # Calculator.add2(1, 2) |
Did we get this right? 👍 / 👎 to inform future reviews.
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.
hmmm
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.
Actually in our team, we put all functions in a utils.py file
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
1 similar comment
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
1 similar comment
|
@sentry review |
This comment has been minimized.
This comment has been minimized.
|
@sentry review |
|
@codecov-ai-reviewer review |
This comment has been minimized.
This comment has been minimized.
| def test_add2(): | ||
| # Test that add2 function raises NameError due to undefined variable 'z' | ||
| with pytest.raises(NameError, match="name 'z' is not defined"): | ||
| Calculator.add2(1, 2) | ||
| Calculator.add2(0, 0) |
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.
The test test_add2() is attempting to test a method Calculator.add2() that doesn't exist in the Calculator class. Based on the calculator.py file, there is no add2 method defined. This test will fail with an AttributeError because the method doesn't exist, not a NameError as expected. You should either:
- Implement the
add2method in the Calculator class if it's intended functionality - Remove this test if it's not needed
- Fix the test to call an existing method if this was a typo
| def test_add2(): | |
| # Test that add2 function raises NameError due to undefined variable 'z' | |
| with pytest.raises(NameError, match="name 'z' is not defined"): | |
| Calculator.add2(1, 2) | |
| Calculator.add2(0, 0) | |
| # If you intended to test the existing 'add' method: | |
| def test_add2(): | |
| # Test additional scenarios for the add function | |
| assert Calculator.add(5, 7) == 12 | |
| assert Calculator.add(-1, 1) == 0 | |
| assert Calculator.add(0.5, 0.5) == 1.0 |
Did we get this right? 👍 / 👎 to inform future reviews.
| # Test that add2 function raises NameError due to undefined variable 'z' | ||
| with pytest.raises(NameError, match="name 'z' is not defined"): |
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.
The test expects a NameError with the message "name 'z' is not defined", but this doesn't make sense in the context of testing a calculator method. This suggests the test is either:
- Testing some internal implementation detail that references an undefined variable 'z'
- Copy-pasted from another context
- Not properly designed for the intended functionality
Tests should focus on the public API and expected behavior, not internal implementation errors.
| # Test that add2 function raises NameError due to undefined variable 'z' | |
| with pytest.raises(NameError, match="name 'z' is not defined"): | |
| # Test should focus on expected behavior, for example: | |
| # with pytest.raises(TypeError, match="missing 1 required positional argument"): | |
| # Calculator.add(1) # Missing second argument |
Did we get this right? 👍 / 👎 to inform future reviews.
|
@sentry review |
| def test_add2(): | ||
| # Test that add2 function raises NameError due to undefined variable 'z' | ||
| with pytest.raises(NameError, match="name 'z' is not defined"): | ||
| Calculator.add2(1, 2) |
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.
The test is attempting to call Calculator.add2() which doesn't exist in the Calculator class. Based on the calculator.py file, there is no add2 method defined. This test will fail with an AttributeError before it can test for the expected NameError. Either implement the add2 method in the Calculator class or remove this test if it's not needed.
| def test_add2(): | |
| # Test that add2 function raises NameError due to undefined variable 'z' | |
| with pytest.raises(NameError, match="name 'z' is not defined"): | |
| Calculator.add2(1, 2) | |
| # Either implement Calculator.add2() method or remove this test | |
| # If testing error handling, ensure the method exists first |
Did we get this right? 👍 / 👎 to inform future reviews.
This PR adds tests for #23
Commits: