◐ Shell
clean mode source ↗

Update test/test_weakset.py from CPython 3.11.2 by dalinaum · Pull Request #4657 · RustPython/RustPython

@@ -1,5 +1,6 @@ import unittest from weakref import WeakSet import copy import string from collections import UserString as ustr from collections.abc import Set, MutableSet Expand All @@ -15,6 +16,12 @@ class RefCycle: def __init__(self): self.cycle = self
class WeakSetSubclass(WeakSet): pass
class WeakSetWithSlots(WeakSet): __slots__ = ('x', 'y')

class TestWeakSet(unittest.TestCase):
Expand Down Expand Up @@ -455,6 +462,32 @@ def test_abc(self): self.assertIsInstance(self.s, Set) self.assertIsInstance(self.s, MutableSet)
# TODO: RUSTPYTHON @unittest.expectedFailure def test_copying(self): for cls in WeakSet, WeakSetWithSlots: s = cls(self.items) s.x = ['x'] s.z = ['z']
dup = copy.copy(s) self.assertIsInstance(dup, cls) self.assertEqual(dup, s) self.assertIsNot(dup, s) self.assertIs(dup.x, s.x) self.assertIs(dup.z, s.z) self.assertFalse(hasattr(dup, 'y'))
dup = copy.deepcopy(s) self.assertIsInstance(dup, cls) self.assertEqual(dup, s) self.assertIsNot(dup, s) self.assertEqual(dup.x, s.x) self.assertIsNot(dup.x, s.x) self.assertEqual(dup.z, s.z) self.assertIsNot(dup.z, s.z) self.assertFalse(hasattr(dup, 'y'))

if __name__ == "__main__": unittest.main()