Skip to content
Merged
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
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
arihant2math committed Apr 18, 2025
commit 4b95a52a21fdc487e432159241700b1c8424ff5e
4 changes: 4 additions & 0 deletions Lib/test/test_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,8 @@ def new_method(self):
c = Alias(10, 1.0)
self.assertEqual(c.new_method(), 1.0)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_generic_dynamic(self):
T = TypeVar('T')

Expand Down Expand Up @@ -3250,6 +3252,8 @@ def test_classvar_module_level_import(self):
# won't exist on the instance.
self.assertNotIn('not_iv4', c.__dict__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_text_annotations(self):
from test import dataclass_textanno

Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,17 @@ def testConversions(self):

self.assertTypedEquals(0.1+0j, complex(F(1,10)))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def testSupportsInt(self):
# See bpo-44547.
f = F(3, 2)
self.assertIsInstance(f, typing.SupportsInt)
self.assertEqual(int(f), 1)
self.assertEqual(type(int(f)), int)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def testIntGuaranteesIntReturn(self):
# Check that int(some_fraction) gives a result of exact type `int`
# even if the fraction is using some other Integral type for its
Expand Down
10 changes: 10 additions & 0 deletions Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def test_exposed_type(self):
self.assertEqual(a.__args__, (int,))
self.assertEqual(a.__parameters__, ())

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_parameters(self):
from typing import List, Dict, Callable
D0 = dict[str, int]
Expand Down Expand Up @@ -212,6 +214,8 @@ def test_parameters(self):
self.assertEqual(L5.__args__, (Callable[[K, V], K],))
self.assertEqual(L5.__parameters__, (K, V))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_parameter_chaining(self):
from typing import List, Dict, Union, Callable
self.assertEqual(list[T][int], list[int])
Expand Down Expand Up @@ -271,6 +275,8 @@ class MyType(type):
with self.assertRaises(TypeError):
MyType[int]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_pickle(self):
alias = GenericAlias(list, T)
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
Expand All @@ -280,6 +286,8 @@ def test_pickle(self):
self.assertEqual(loaded.__args__, alias.__args__)
self.assertEqual(loaded.__parameters__, alias.__parameters__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_copy(self):
class X(list):
def __copy__(self):
Expand All @@ -303,6 +311,8 @@ def test_union(self):
self.assertEqual(a.__args__, (list[int], list[str]))
self.assertEqual(a.__parameters__, ())

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_generic(self):
a = typing.Union[list[T], tuple[T, ...]]
self.assertEqual(a.__args__, (list[T], tuple[T, ...]))
Expand Down
16 changes: 16 additions & 0 deletions Lib/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ def test_instancecheck_and_subclasscheck(self):
self.assertTrue(issubclass(dict, x))
self.assertFalse(issubclass(list, x))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_instancecheck_and_subclasscheck_order(self):
T = typing.TypeVar('T')

Expand Down Expand Up @@ -788,13 +790,17 @@ def __subclasscheck__(cls, sub):
self.assertTrue(issubclass(int, x))
self.assertRaises(ZeroDivisionError, issubclass, list, x)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_or_type_operator_with_TypeVar(self):
TV = typing.TypeVar('T')
assert TV | str == typing.Union[TV, str]
assert str | TV == typing.Union[str, TV]
self.assertIs((int | TV)[int], int)
self.assertIs((TV | int)[int], int)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_args(self):
def check(arg, expected):
clear_typing_caches()
Expand Down Expand Up @@ -825,6 +831,8 @@ def check(arg, expected):
check(x | None, (x, type(None)))
check(None | x, (type(None), x))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_parameter_chaining(self):
T = typing.TypeVar("T")
S = typing.TypeVar("S")
Expand Down Expand Up @@ -869,6 +877,8 @@ def eq(actual, expected, typed=True):
eq(x[NT], int | NT | bytes)
eq(x[S], int | S | bytes)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_pickle(self):
orig = list[T] | int
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
Expand All @@ -878,19 +888,25 @@ def test_union_pickle(self):
self.assertEqual(loaded.__args__, orig.__args__)
self.assertEqual(loaded.__parameters__, orig.__parameters__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_copy(self):
orig = list[T] | int
for copied in (copy.copy(orig), copy.deepcopy(orig)):
self.assertEqual(copied, orig)
self.assertEqual(copied.__args__, orig.__args__)
self.assertEqual(copied.__parameters__, orig.__parameters__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_parameter_substitution_errors(self):
T = typing.TypeVar("T")
x = int | T
with self.assertRaises(TypeError):
x[int, str]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_or_type_operator_with_forward(self):
T = typing.TypeVar('T')
ForwardAfter = T | 'Forward'
Expand Down