10000 mark failing tests · RustPython/RustPython@9caa7b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9caa7b8

Browse files
committed
mark failing tests
1 parent ac3dfe0 commit 9caa7b8

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

Lib/dataclasses.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,26 +1167,28 @@ def _dataclass_setstate(self, state):
11671167

11681168

11691169
def _get_slots(cls):
1170-
match cls.__dict__.get('__slots__'):
1170+
__slots__ = cls.__dict__.get('__slots__')
11711171
# `__dictoffset__` and `__weakrefoffset__` can tell us whether
11721172
# the base type has dict/weakref slots, in a way that works correctly
11731173
# for both Python classes and C extension types. Extension types
11741174
# don't use `__slots__` for slot creation
1175-
case None:
1175+
if __slots__ is None:
11761176
slots = []
11771177
if getattr(cls, '__weakrefoffset__', -1) != 0:
11781178
slots.append('__weakref__')
11791179
if getattr(cls, '__dictrefoffset__', -1) != 0:
11801180
slots.append('__dict__')
11811181
yield from slots
1182-
case str(slot):
1182+
elif type(__slots__) is str:
1183+
slot = __slots__
11831184
yield slot
1184-
# Slots may be any iterable, but we cannot handle an iterator
1185-
# because it will already be (partially) consumed.
1186-
case iterable if not hasattr(iterable, '__next__'):
1187-
yield from iterable
1188-
case _:
1189-
raise TypeError(f"Slots of '{cls.__name__}' cannot be determined")
1185+
# Slots may be any iterable, but we cannot handle an iterator
1186+
# because it will already be (partially) consumed.
1187+
elif not hasattr(__slots__, '__next__'):
1188+
iterable = __slots__
1189+
yield from iterable
1190+
else:
1191+
raise TypeError(f"Slots of '{cls.__name__}' cannot be determined")
11901192

11911193

11921194
def _add_slots(cls, is_frozen, weakref_slot):

Lib/test/test_dataclasses/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,8 @@ def __post_init__(self, init_param):
12791279
c = C(init_param=10)
12801280
self.assertEqual(c.x, 20)
12811281

1282+
# TODO: RUSTPYTHON
1283+
@unittest.expectedFailure
128212 8000 84
def test_init_var_preserve_type(self):
12831285
self.assertEqual(InitVar[int].type, int)
12841286

@@ -1537,6 +1539,8 @@ class B:
15371539
with self.assertRaisesRegex(TypeError, 'should be called on dataclass instances'):
15381540
replace(obj, x=0)
15391541

1542+
# TODO: RUSTPYTHON
1543+
@unittest.expectedFailure
15401544
def test_is_dataclass_genericalias(self):
15411545
@dataclass
15421546
class A(types.GenericAlias):
@@ -1775,6 +1779,8 @@ class C:
17751779
self.assertIsNot(d['f'], t)
17761780
self.assertEqual(d['f'].my_a(), 6)
17771781

1782+
# TODO: RUSTPYTHON
1783+
@unittest.expectedFailure
17781784
def test_helper_asdict_defaultdict(self):
17791785
# Ensure asdict() does not throw exceptions when a
17801786
# defaultdict is a member of a dataclass
@@ -1917,6 +1923,8 @@ class C:
19171923
t = astuple(c, tuple_factory=list)
19181924
self.assertEqual(t, ['outer', T(1, ['inner', T(11, 12, 13)], 2)])
19191925

1926+
# TODO: RUSTPYTHON
1927+
@unittest.expectedFailure
19201928
def test_helper_astuple_defaultdict(self):
19211929
# Ensure astuple() does not throw exceptions when a
19221930
# defaultdict is a member of a dataclass
@@ -2327,13 +2335,17 @@ class C:
23272335

23282336
self.assertDocStrEqual(C.__doc__, "C(x:List[int]=<factory>)")
23292337

2338+
# TODO: RUSTPYTHON
2339+
@unittest.expectedFailure
23302340
def test_docstring_deque_field(self):
23312341
@dataclass
23322342
class C:
23332343
x: deque
23342344

23352345
self.assertDocStrEqual(C.__doc__, "C(x:collections.deque)")
23362346

2347+
# TODO: RUSTPYTHON
2348+
@unittest.expectedFailure
23372349
def test_docstring_deque_field_with_default_factory(self):
23382350
@dataclass
23392351
class C:
@@ -3073,6 +3085,8 @@ class C:
30733085

30743086

30753087
class TestSlots(unittest.TestCase):
3088+
# TODO: RUSTPYTHON
3089+
@unittest.expectedFailure
30763090
def test_simple(self):
30773091
@dataclass
30783092
class C:
@@ -3114,6 +3128,8 @@ class Derived(Base):
31143128
# We can add a new field to the derived instance.
31153129
d.z = 10
31163130

3131+
# TODO: RUSTPYTHON
3132+
@unittest.expectedFailure
31173133
def test_generated_slots(self):
31183134
@dataclass(slots=True)
31193135
class C:
@@ -3318,6 +3334,8 @@ class A:
33183334
self.assertEqual(obj.a, 'a')
33193335
self.assertEqual(obj.b, 'b')
33203336

3337+
# TODO: RUSTPYTHON
3338+
@unittest.expectedFailure
33213339
def test_slots_no_weakref(self):
33223340
@dataclass(slots=True)
33233341
class A:
@@ -3332,6 +3350,8 @@ class A:
33323350
with self.assertRaises(AttributeError):
33333351
a.__weakref__
33343352

3353+
# TODO: RUSTPYTHON
3354+
@unittest.expectedFailure
33353355
def test_slots_weakref(self):
33363356
@dataclass(slots=True, weakref_slot=True)
33373357
class A:
@@ -3392,6 +3412,8 @@ def test_weakref_slot_make_dataclass(self):
33923412
"weakref_slot is True but slots is False"):
33933413
B = make_dataclass('B', [('a', int),], weakref_slot=True)
33943414

3415+
# TODO: RUSTPYTHON
3416+
@unittest.expectedFailure
33953417
def test_weakref_slot_subclass_weakref_slot(self):
33963418
@dataclass(slots=True, weakref_slot=True)
33973419
class Base:
@@ -3410,6 +3432,8 @@ class A(Base):
34103432
a_ref = weakref.ref(a)
34113433
self.assertIs(a.__weakref__, a_ref)
34123434

3435+
# TODO: RUSTPYTHON
3436+
@unittest.expectedFailure
34133437
def test_weakref_slot_subclass_no_weakref_slot(self):
34143438
@dataclass(slots=True, weakref_slot=True)
34153439
class Base:
@@ -3427,6 +3451,8 @@ class A(Base):
34273451
a_ref = weakref.ref(a)
34283452
self.assertIs(a.__weakref__, a_ref)
34293453

3454+
# TODO: RUSTPYTHON
3455+
@unittest.expectedFailure
34303456
def test_weakref_slot_normal_base_weakref_slot(self):
34313457
class Base:
34323458
__slots__ = ('__weakref__',)
@@ -3472,6 +3498,8 @@ class B[T2]:
34723498
self.assertTrue(B.__weakref__)
34733499
B()
34743500

3501+
# TODO: RUSTPYTHON
3502+
@unittest.expectedFailure
34753503
def test_dataclass_derived_generic_from_base(self):
34763504
T = typing.TypeVar('T')
34773505

@@ -4513,6 +4541,8 @@ class C:
45134541
b: int = field(kw_only=True)
45144542
self.assertEqual(C(42, b=10).__match_args__, ('a',))
45154543

4544+
# TODO: RUSTPYTHON
4545+
@unittest.expectedFailure
45164546
def test_KW_ONLY(self):
45174547
@dataclass
45184548
class A:

0 commit comments

Comments
 (0)
0