-
Notifications
You must be signed in to change notification settings - Fork 48
Update to pass under the latest flake8-bugbear #1432
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| """ | ||
| Several errors define `__reduce__` to ensure that they are pickleable. | ||
|
|
||
| These tests ensure that we can copy without errors and that the results compare equal | ||
| under some definition of "equal" (which may be specific to the error type). | ||
| """ | ||
|
|
||
| import copy | ||
|
|
||
| from globus_sdk.exc import NetworkError | ||
| from globus_sdk.scopes.consents import ConsentParseError, ConsentTreeConstructionError | ||
| from globus_sdk.token_storage.validating_token_storage import ( | ||
| ExpiredTokenError, | ||
| IdentityMismatchError, | ||
| MissingTokenError, | ||
| UnmetScopeRequirementsError, | ||
| ) | ||
|
|
||
|
|
||
| def test_copy_of_network_error(): | ||
| err = NetworkError("bad cxn", Exception("kaboom")) | ||
| err_copy = copy.copy(err) | ||
| assert id(err) != id(err_copy) | ||
| assert str(err_copy.underlying_exception) == "kaboom" | ||
|
|
||
|
|
||
| def test_copy_of_identity_mismatch_error(): | ||
| err = IdentityMismatchError("they didn't match", "a", "b") | ||
| err_copy = copy.copy(err) | ||
| assert id(err) != id(err_copy) | ||
| assert ( | ||
| err.message, | ||
| err.stored_id, | ||
| err.new_id, | ||
| ) == ( | ||
| err_copy.message, | ||
| err_copy.stored_id, | ||
| err_copy.new_id, | ||
| ) | ||
|
|
||
|
|
||
| def test_copy_of_missing_token_error(): | ||
| err = MissingTokenError("it gone", "my_rs") | ||
| err_copy = copy.copy(err) | ||
| assert id(err) != id(err_copy) | ||
| assert ( | ||
| err.message, | ||
| err.resource_server, | ||
| ) == ( | ||
| err_copy.message, | ||
| err_copy.resource_server, | ||
| ) | ||
|
|
||
|
|
||
| def test_copy_of_expired_token_error(): | ||
| err = ExpiredTokenError(101) | ||
| err_copy = copy.copy(err) | ||
| assert id(err) != id(err_copy) | ||
| assert ( | ||
| err.message, | ||
| err.expiration, | ||
| ) == ( | ||
| err_copy.message, | ||
| err_copy.expiration, | ||
| ) | ||
|
|
||
|
|
||
| def test_copy_of_scope_requirements_error(): | ||
| err = UnmetScopeRequirementsError("needed a token for scope", {"my_rs": []}) | ||
| err_copy = copy.copy(err) | ||
| assert id(err) != id(err_copy) | ||
| assert ( | ||
| err.message, | ||
| err.scope_requirements, | ||
| ) == ( | ||
| err_copy.message, | ||
| err_copy.scope_requirements, | ||
| ) | ||
|
|
||
|
|
||
| def test_copy_of_consent_parse_error(): | ||
| err = ConsentParseError("it didn't parse", {}) | ||
| err_copy = copy.copy(err) | ||
| assert id(err) != id(err_copy) | ||
| assert ( | ||
| err.message, | ||
| err.raw_consent, | ||
| ) == ( | ||
| err_copy.message, | ||
| err_copy.raw_consent, | ||
| ) | ||
|
|
||
|
|
||
| def test_copy_of_consent_tree_construction_error(): | ||
| err = ConsentTreeConstructionError("empty", []) | ||
| err_copy = copy.copy(err) | ||
| assert id(err) != id(err_copy) | ||
| assert ( | ||
| err.message, | ||
| err.consents, | ||
| ) == ( | ||
| err_copy.message, | ||
| err_copy.consents, | ||
| ) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """ | ||
| Several errors define `__str__` to ensure that args are formatted | ||
| (or dropped) as desired. These tests ensure that we get the right strings back. | ||
| """ | ||
|
|
||
| from globus_sdk.exc import NetworkError | ||
| from globus_sdk.scopes.consents import ConsentParseError, ConsentTreeConstructionError | ||
| from globus_sdk.token_storage.validating_token_storage import ( | ||
| ExpiredTokenError, | ||
| IdentityMismatchError, | ||
| MissingTokenError, | ||
| UnmetScopeRequirementsError, | ||
| ) | ||
|
|
||
|
|
||
| def test_str_of_network_error(): | ||
| err = NetworkError("bad cxn", Exception("kaboom")) | ||
| assert str(err) == "bad cxn" | ||
|
|
||
|
|
||
| def test_str_of_identity_mismatch_error(): | ||
| err = IdentityMismatchError("they didn't match", "a", "b") | ||
| assert str(err) == "they didn't match" | ||
|
|
||
|
|
||
| def test_str_of_missing_token_error(): | ||
| err = MissingTokenError("it gone", "my_rs") | ||
| assert str(err) == "it gone" | ||
|
|
||
|
|
||
| def test_str_of_expired_token_error(): | ||
| err = ExpiredTokenError(101) | ||
| assert str(err).startswith("Token expired at ") | ||
|
|
||
|
|
||
| def test_str_of_scope_requirements_error(): | ||
| err = UnmetScopeRequirementsError("needed a token for scope", {"my_rs": []}) | ||
| assert str(err) == "needed a token for scope" | ||
|
|
||
|
|
||
| def test_str_of_consent_parse_error(): | ||
| err = ConsentParseError("it didn't parse", {}) | ||
| assert str(err) == "it didn't parse" | ||
|
|
||
|
|
||
| def test_str_of_consent_tree_construction_error(): | ||
| err = ConsentTreeConstructionError("empty", []) | ||
| assert str(err) == "empty" |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.