FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update test_context from Cpython v3.11.2 by Masorubka1 · Pull Request #4805 · RustPython/RustPython · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
43 changes: 37 additions & 6 deletions Lib/test/test_context.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
import unittest
import weakref
from test.support import threading_helper

try:
from _testcapi import hamt
Expand Down Expand Up @@ -379,6 +380,7 @@ def ctx2_fun():
# TODO: RUSTPYTHON
@unittest.expectedFailure
@isolated_context
@threading_helper.requires_working_threading()
def test_context_threads_1(self):
cvar = contextvars.ContextVar('cvar')

Expand All @@ -396,12 +398,6 @@ def sub(num):
tp.shutdown()
self.assertEqual(results, list(range(10)))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_contextvar_getitem(self):
clss = contextvars.ContextVar
self.assertEqual(clss[str], clss)


# HAMT Tests

Expand Down Expand Up @@ -577,6 +573,41 @@ def test_hamt_collision_1(self):
self.assertEqual(len(h4), 2)
self.assertEqual(len(h5), 3)

def test_hamt_collision_3(self):
# Test that iteration works with the deepest tree possible.
# https://github.com/python/cpython/issues/93065

C = HashKey(0b10000000_00000000_00000000_00000000, 'C')
D = HashKey(0b10000000_00000000_00000000_00000000, 'D')

E = HashKey(0b00000000_00000000_00000000_00000000, 'E')

h = hamt()
h = h.set(C, 'C')
h = h.set(D, 'D')
h = h.set(E, 'E')

# BitmapNode(size=2 count=1 bitmap=0b1):
# NULL:
# BitmapNode(size=2 count=1 bitmap=0b1):
# NULL:
# BitmapNode(size=2 count=1 bitmap=0b1):
# NULL:
# BitmapNode(size=2 count=1 bitmap=0b1):
# NULL:
# BitmapNode(size=2 count=1 bitmap=0b1):
# NULL:
# BitmapNode(size=2 count=1 bitmap=0b1):
# NULL:
# BitmapNode(size=4 count=2 bitmap=0b101):
# <Key name:E hash:0>: 'E'
# NULL:
# CollisionNode(size=4 id=0x107a24520):
# <Key name:C hash:2147483648>: 'C'
# <Key name:D hash:2147483648>: 'D'

self.assertEqual({k.name for k in h.keys()}, {'C', 'D', 'E'})

def test_hamt_stress(self):
COLLECTION_SIZE = 7000
TEST_ITERS_EVERY = 647
Expand Down

Back | FazBrowse Home | New Git URL