Skip to content

Commit

Permalink
Refactoring of some tests.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 730849087
  • Loading branch information
Martin Huschenbett authored and copybara-github committed Feb 25, 2025
1 parent 2d0c6ed commit b168370
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pytype/tests/test_attr2.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Foo:
""")

def test_converter_with_varargs(self):
self.CheckWithErrors("""
self.Check("""
import attr
def convert(*args, **kwargs) -> int:
return 42
Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_classes1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ def f() -> C[int]: ...
self.assertErrorRegexes(errors, {"e": r"C"})

def test_call_parameterized_class(self):
self.InferWithErrors("""
self.Check("""
from typing import Deque
list[str]()
Deque[str]()
Expand Down
4 changes: 2 additions & 2 deletions pytype/tests/test_dataclass_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TestFunction(test_base.BaseTest):
"""Tests for @dataclass_transform on functions."""

def test_py_function(self):
self.CheckWithErrors("""
self.Check("""
from typing_extensions import dataclass_transform
# NOTE: The decorator overrides the function body and makes `dc` a
Expand Down Expand Up @@ -233,7 +233,7 @@ def __init__(self, x: int) -> None: ...
)

def test_write_pyi(self):
ty, _ = self.InferWithErrors("""
ty = self.Infer("""
from typing_extensions import dataclass_transform
@dataclass_transform()
class Mixin: ...
Expand Down
4 changes: 2 additions & 2 deletions pytype/tests/test_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class M(enum.Enum):
def get_m(name: str) -> M: ...
""",
)
self.CheckWithErrors(
self.Check(
"""
import foo
def print_m(name: str):
Expand Down Expand Up @@ -1331,7 +1331,7 @@ class NoFn(enum.Enum):
x: Annotated[str, 'property']
""",
)
self.CheckWithErrors(
self.Check(
"""
import foo
assert_type(foo.Fn.A.value, int)
Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_fiddle_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def __init__(self: Simple, x: int, y: str): ...

def test_typevar(self):
with self.DepTree([("fiddle.pyi", _FIDDLE_PYI)]):
self.CheckWithErrors(f"""
self.Check(f"""
import dataclasses
import fiddle
from typing import TypeVar
Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_import1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ class X:
init_pyi_1, _ = self.InferWithErrors(
init_py % " # import-error", module_name="mod.__init__"
)
submod_pyi_1, _ = self.InferWithErrors(submod_py, module_name="mod.submod")
submod_pyi_1 = self.Infer(submod_py, module_name="mod.submod")
with test_utils.Tempdir() as d:
init_path = d.create_file(
file_utils.replace_separator("mod/__init__.pyi"),
Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_list2.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_getitem_slot(self):

def test_slice_returntype(self):
# each of the superclasses of list should return their own type when sliced.
ty, _ = self.InferWithErrors("""
ty = self.Infer("""
from typing import Sequence, MutableSequence
a: Sequence[int] = [1]
b = a[0:1]
Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_match2.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def baz(os: Optional[str]):
""")

def test_optional_str_against_plain_iterable(self):
self.CheckWithErrors("""
self.Check("""
from typing import Iterable, Optional
def foo(x: Iterable): ...
Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_methods1.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ def f():
)

def test_func_name(self):
ty, _ = self.InferWithErrors("""
ty = self.Infer("""
def f():
pass
f.func_name = 3.1415
Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_operators1.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def test_subscr(self):
# Make sure we don't crash due to __path__[0] having no bindings. Previously
# we were not setting __path__[0] to [unsolvable] if report_errors was False
self.options.tweak(report_errors=False)
self.InferWithErrors("""
self.Check("""
{ 'path': __path__[0] }
""")

Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_paramspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def f(x: str) -> int: ...
def f(x: str, *, y: int = 0) -> int: ...
""",
)]):
ty, _ = self.InferWithErrors("""
ty = self.Infer("""
import foo
f = foo.decorator(foo.f)
Expand Down
4 changes: 2 additions & 2 deletions pytype/tests/test_typeguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class PyiTest(test_base.BaseTest):

@test_utils.skipBeforePy((3, 10), "New in 3.10")
def test_infer(self):
ty, _ = self.InferWithErrors("""
ty = self.Infer("""
from typing import TypeGuard
def f(x: object) -> TypeGuard[int]:
return isinstance(x, int)
Expand All @@ -94,7 +94,7 @@ def f(x: object) -> TypeGuard[int]: ...
)

def test_infer_extension(self):
ty, _ = self.InferWithErrors("""
ty = self.Infer("""
from typing_extensions import TypeGuard
def f(x: object) -> TypeGuard[int]:
return isinstance(x, int)
Expand Down
2 changes: 1 addition & 1 deletion pytype/tests/test_typing_namedtuple2.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class X(NamedTuple):
b: int
""",
)
ty, unused_errorlog = self.InferWithErrors(
ty = self.Infer(
"""
import foo
v = None # type: foo.X
Expand Down

0 comments on commit b168370

Please sign in to comment.