-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move info_utils errors to exceptions module (#6952)
* Move info_utils errors to exceptions module * Create new errors and deprecate old ones * Replace deprecated errors * Make deprecation backward compatible * Test deprecated and non-deprecated errors * Fix non-deprecated errors
- Loading branch information
1 parent
9510252
commit 37a6036
Showing
4 changed files
with
188 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,58 @@ | ||
import warnings | ||
|
||
import pytest | ||
|
||
import datasets.utils.deprecation_utils | ||
from datasets.exceptions import ( | ||
ChecksumVerificationError, | ||
ChecksumVerificationException, | ||
ExpectedMoreDownloadedFiles, | ||
ExpectedMoreDownloadedFilesError, | ||
ExpectedMoreSplits, | ||
ExpectedMoreSplitsError, | ||
NonMatchingChecksumError, | ||
NonMatchingSplitsSizesError, | ||
SplitsVerificationError, | ||
SplitsVerificationException, | ||
UnexpectedDownloadedFile, | ||
UnexpectedDownloadedFileError, | ||
UnexpectedSplits, | ||
UnexpectedSplitsError, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"error", | ||
[ | ||
ChecksumVerificationException, | ||
UnexpectedDownloadedFile, | ||
ExpectedMoreDownloadedFiles, | ||
SplitsVerificationException, | ||
UnexpectedSplits, | ||
ExpectedMoreSplits, | ||
], | ||
) | ||
def test_error_deprecated(error, monkeypatch): | ||
monkeypatch.setattr(datasets.utils.deprecation_utils, "_emitted_deprecation_warnings", set()) | ||
with pytest.deprecated_call(): | ||
error() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"error", | ||
[ | ||
ChecksumVerificationError, | ||
UnexpectedDownloadedFileError, | ||
ExpectedMoreDownloadedFilesError, | ||
NonMatchingChecksumError, | ||
SplitsVerificationError, | ||
UnexpectedSplitsError, | ||
ExpectedMoreSplitsError, | ||
NonMatchingSplitsSizesError, | ||
], | ||
) | ||
def test_error_not_deprecated(error, monkeypatch): | ||
monkeypatch.setattr(datasets.utils.deprecation_utils, "_emitted_deprecation_warnings", set()) | ||
with warnings.catch_warnings(): | ||
warnings.simplefilter("error") | ||
error() |