Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mypyc/test-data/fixtures/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __ne__(self, x: object) -> bool: pass
class type:
def __init__(self, o: object) -> None: ...
def __or__(self, o: object) -> Any: ...
def __new__(cls, *args: object) -> Any: ...
__name__ : str
__annotations__: Dict[str, Any]

Expand Down
8 changes: 4 additions & 4 deletions mypyc/test-data/run-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ def test_classmethod_with_allow_interpreted() -> None:

[file interp.py]
def make_interpreted_subclass(base):
class Sub(base):
class Sub(base): # type: ignore
@classmethod
def g(cls, x: int) -> int:
return x + 3
Expand Down Expand Up @@ -2473,7 +2473,7 @@ def test_interpreted_subclass() -> None:
from testutil import assertRaises

def define_interpreted_subclass(b):
class DerivedInterpreted1(b):
class DerivedInterpreted1(b): # type: ignore
def __init__(self):
# Don't call base class __init__
pass
Expand All @@ -2486,10 +2486,10 @@ def define_interpreted_subclass(b):
with assertRaises(AttributeError):
del d1.x

class DerivedInterpreted1(b):
class DerivedInterpreted2(b): # type: ignore
def __init__(self):
super().__init__('y')
d2 = DerivedInterpreted1()
d2 = DerivedInterpreted2()
assert d2.x == 5
assert d2.s == 'y'
with assertRaises(AttributeError):
Expand Down
21 changes: 11 additions & 10 deletions mypyc/test-data/run-singledispatch.test
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,17 @@ def build(n: int) -> Tree:
return Leaf()
return Node(n, build(n - 1), build(n - 1))

def test_sum_and_equal():
tree = build(5)
tree2 = build(5)
tree2.right.right.right.value = 10
assert calc_sum(tree) == 57
assert calc_sum(tree2) == 65
assert equal(tree, tree)
assert not equal(tree, tree2)
tree3 = build(4)
assert not equal(tree, tree3)
[file driver.py]
from native import build, calc_sum, equal
tree = build(5)
tree2 = build(5)
tree2.right.right.right.value = 10
assert calc_sum(tree) == 57
assert calc_sum(tree2) == 65
assert equal(tree, tree)
assert not equal(tree, tree2)
tree3 = build(4)
assert not equal(tree, tree3)

[case testSimulateMypySingledispatch]
from functools import singledispatch
Expand Down
13 changes: 4 additions & 9 deletions mypyc/test-data/run-weakref.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Test cases for weakrefs (compile and run)

[case testWeakrefRef]
# TODO: fixme
[case testWeakrefRef-xfail]
from weakref import ref
from mypy_extensions import mypyc_attr

Expand All @@ -9,22 +10,16 @@ class Object:
"""some random weakreffable object"""
pass

def test_weakref_ref():
def test_weakref_ref() -> None:
obj = Object()
r = ref(obj)
assert r() is obj
obj = None
assert r() is None, r()

def test_weakref_ref_with_callback():
def test_weakref_ref_with_callback() -> None:
obj = Object()
r = ref(obj, lambda x: x)
assert r() is obj
obj = None
assert r() is None, r()

[file driver.py]
from native import test_weakref_ref, test_weakref_ref_with_callback

test_weakref_ref()
test_weakref_ref_with_callback()
1 change: 1 addition & 0 deletions mypyc/test/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def run_case_step(self, testcase: DataDrivenTestCase, incremental_step: int) ->
options.preserve_asts = True
options.allow_empty_bodies = True
options.incremental = self.separate
options.check_untyped_defs = True

# Avoid checking modules/packages named 'unchecked', to provide a way
# to test interacting with code we don't have types for.
Expand Down
Loading