Conversation
…latitude and longitude
There was a problem hiding this comment.
Pull Request Overview
This PR updates the test_geonames_query to assert that resolver.resolve returns a dictionary with latitude and longitude keys and validates the expected coordinates for New York, US.
- Changed return type assertion from tuple to dict
- Added key presence checks for
latitudeandlongitude - Added strict value comparison for the expected coordinates
Comments suppressed due to low confidence (1)
tests/test_resolver.py:19
- [nitpick] The numbering prefix '2.' in the assertion message is unnecessary and may clutter output; remove it for clearer error messages.
assert isinstance(coordinates, dict), "2. Coordinates should be a dict"
Comment on lines
+18
to
+21
| assert coordinates is not None, "1. Coordinates should not be None" | ||
| assert isinstance(coordinates, dict), "2. Coordinates should be a dict" | ||
| assert "latitude" in coordinates and "longitude" in coordinates, "3. Coordinates should contain latitude and longitude" | ||
| assert coordinates["latitude"] == 40.71427 and coordinates["longitude"] == -74.00597, f"4. Coordinates {coordinates} do not match expected values for New York, US" No newline at end of file |
There was a problem hiding this comment.
[nitpick] The explicit None check may be redundant as subsequent assertions will fail on None; consider removing it to simplify the test.
Suggested change
| assert coordinates is not None, "1. Coordinates should not be None" | |
| assert isinstance(coordinates, dict), "2. Coordinates should be a dict" | |
| assert "latitude" in coordinates and "longitude" in coordinates, "3. Coordinates should contain latitude and longitude" | |
| assert coordinates["latitude"] == 40.71427 and coordinates["longitude"] == -74.00597, f"4. Coordinates {coordinates} do not match expected values for New York, US" | |
| assert isinstance(coordinates, dict), "1. Coordinates should be a dict" | |
| assert "latitude" in coordinates and "longitude" in coordinates, "2. Coordinates should contain latitude and longitude" | |
| assert coordinates["latitude"] == 40.71427 and coordinates["longitude"] == -74.00597, f"3. Coordinates {coordinates} do not match expected values for New York, US" |
| assert coordinates is not None, "1. Coordinates should not be None" | ||
| assert isinstance(coordinates, dict), "2. Coordinates should be a dict" | ||
| assert "latitude" in coordinates and "longitude" in coordinates, "3. Coordinates should contain latitude and longitude" | ||
| assert coordinates["latitude"] == 40.71427 and coordinates["longitude"] == -74.00597, f"4. Coordinates {coordinates} do not match expected values for New York, US" No newline at end of file |
There was a problem hiding this comment.
Directly comparing floats can lead to flaky tests; consider using pytest.approx for approximate comparisons of latitude and longitude values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…latitude and longitude