-
-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76a71b1
commit e510b5c
Showing
2 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"from" | ||
"import" | ||
"with" | ||
"as" |
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,47 @@ | ||
#!/usr/bin/python3 | ||
import sys | ||
import io | ||
import atheris | ||
|
||
|
||
with atheris.instrument_imports(): | ||
import isort | ||
from isort.exceptions import ExistingSyntaxErrors | ||
|
||
|
||
def TestOneInput(data): | ||
fdp = atheris.FuzzedDataProvider(data) | ||
try: | ||
isort.api.check_code_string(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000))) | ||
isort.api.check_stream(io.StringIO(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000)))) | ||
# exceptions caused by invalid inputs - ignore as uninteresting | ||
except (ExistingSyntaxErrors, ValueError): | ||
pass | ||
try: | ||
isort.api.sort_code_string(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000))) | ||
isort.api.sort_stream(io.StringIO(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000))), | ||
io.StringIO(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000)))) | ||
# exceptions caused by invalid inputs - ignore as uninteresting | ||
except (ExistingSyntaxErrors, ValueError): | ||
pass | ||
try: | ||
isort.api.place_module(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000))) | ||
isort.api.place_module_with_reason(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000))) | ||
# exceptions caused by invalid inputs - ignore as uninteresting | ||
except (ValueError, OSError): | ||
pass | ||
isort.api.find_imports_in_stream(io.StringIO(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000)))) | ||
isort.api.find_imports_in_code(fdp.ConsumeUnicodeNoSurrogates( | ||
fdp.ConsumeIntInRange(1, 1000))) | ||
|
||
|
||
atheris.Setup(sys.argv, TestOneInput) | ||
atheris.Fuzz() |