"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "analysis/test/preprocessingTest.ml" between
pyre-check-0.0.53.tar.gz and pyre-check-0.0.54.tar.gz

About: Pyre is a performant type checker for Python (ships with Pysa, a security focused static analysis tool).

preprocessingTest.ml  (pyre-check-0.0.53):preprocessingTest.ml  (pyre-check-0.0.54)
skipping to change at line 2180 skipping to change at line 2180
{ {
Class.name = + !&"foo"; Class.name = + !&"foo";
bases = []; bases = [];
body = [+Statement.Class inner]; body = [+Statement.Class inner];
decorators = []; decorators = [];
top_level_unbound_names = []; top_level_unbound_names = [];
} }
in in
assert_classes [+Statement.Class class_define] [class_define; inner] assert_classes [+Statement.Class class_define] [class_define; inner]
let test_replace_lazy_import _ =
let is_lazy_import { Node.value; _ } =
match value with
| Expression.Name name -> (
match name_to_reference name with
| Some reference when Reference.equal reference (Reference.create "lazy_
import") -> true
| _ -> false )
| _ -> false
in
let assert_replaced source expected =
let parse = parse ~handle:"test.py" in
assert_source_equal
~location_insensitive:true
(parse expected)
(Preprocessing.replace_lazy_import ~is_lazy_import (parse source))
in
assert_replaced {|
x = lazy_import("a.b.c")
|} {|
import a.b.c as x
|};
assert_replaced {|
x: Any = lazy_import("a.b.c")
|} {|
import a.b.c as x
|};
assert_replaced
{|
x = lazy_import("a.b", "c")
|}
{|
from a.b import c as x
|};
assert_replaced
{|
if derp:
x = lazy_import("a.b.c")
else:
y = lazy_import("a.b", "c")
|}
{|
if derp:
import a.b.c as x
else:
from a.b import c as y
|};
assert_replaced
{|
while derp:
x = lazy_import("a.b.c")
else:
y = lazy_import("a.b", "c")
|}
{|
while derp:
import a.b.c as x
else:
from a.b import c as y
|};
assert_replaced
{|
with derp as d:
x = lazy_import("a.b.c")
|}
{|
with derp as d:
import a.b.c as x
|};
assert_replaced
{|
try:
x = lazy_import("a.b.c")
except:
y = lazy_import("a.b", "c")
finally:
z: Any = lazy_import("a", "b")
|}
{|
try:
import a.b.c as x
except:
from a.b import c as y
finally:
from a import b as z
|};
assert_replaced
{|
def foo():
x = lazy_import("a.b.c")
class Foo:
y = lazy_import("a.b", "c")
|}
{|
def foo():
import a.b.c as x
class Foo:
from a.b import c as y
|};
()
let test_replace_mypy_extensions_stub _ = let test_replace_mypy_extensions_stub _ =
let given = let given =
parse parse
~handle:"mypy_extensions.pyi" ~handle:"mypy_extensions.pyi"
{| {|
from typing import Dict, Type, TypeVar, Optional, Union, Any, Generic from typing import Dict, Type, TypeVar, Optional, Union, Any, Generic
_T = TypeVar('_T') _T = TypeVar('_T')
_U = TypeVar('_U') _U = TypeVar('_U')
skipping to change at line 4392 skipping to change at line 4493
"expand_format_string" >:: test_expand_format_string; "expand_format_string" >:: test_expand_format_string;
"qualify" >:: test_qualify; "qualify" >:: test_qualify;
"replace_version_specific_code" >:: test_replace_version_specific_code; "replace_version_specific_code" >:: test_replace_version_specific_code;
"replace_platform_specific_code" >:: test_replace_platform_specific_cod e; "replace_platform_specific_code" >:: test_replace_platform_specific_cod e;
"expand_type_checking_imports" >:: test_expand_type_checking_imports; "expand_type_checking_imports" >:: test_expand_type_checking_imports;
"expand_wildcard_imports" >:: test_expand_wildcard_imports; "expand_wildcard_imports" >:: test_expand_wildcard_imports;
"expand_implicit_returns" >:: test_expand_implicit_returns; "expand_implicit_returns" >:: test_expand_implicit_returns;
"defines" >:: test_defines; "defines" >:: test_defines;
"classes" >:: test_classes; "classes" >:: test_classes;
"transform_ast" >:: test_transform_ast; "transform_ast" >:: test_transform_ast;
"replace_lazy_import" >:: test_replace_lazy_import;
"typed_dictionary_stub_fix" >:: test_replace_mypy_extensions_stub; "typed_dictionary_stub_fix" >:: test_replace_mypy_extensions_stub;
"typed_dictionaries" >:: test_expand_typed_dictionaries; "typed_dictionaries" >:: test_expand_typed_dictionaries;
"sqlalchemy_declarative_base" >:: test_sqlalchemy_declarative_base; "sqlalchemy_declarative_base" >:: test_sqlalchemy_declarative_base;
"nesting_define" >:: test_populate_nesting_define; "nesting_define" >:: test_populate_nesting_define;
"captures" >:: test_populate_captures; "captures" >:: test_populate_captures;
"unbound_names" >:: test_populate_unbound_names; "unbound_names" >:: test_populate_unbound_names;
] ]
|> Test.run |> Test.run
 End of changes. 2 change blocks. 
0 lines changed or deleted 103 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)