(self)
| 357 | @threading_helper.requires_working_threading() |
| 358 | @unittest.skipIf(sys.platform == 'darwin', 'TODO: RUSTPYTHON; Flaky on Mac, self.assertEqual(cvar.get(), num + i) AssertionError: 8 != 12') |
| 359 | def test_context_threads_1(self): |
| 360 | cvar = contextvars.ContextVar('cvar') |
| 361 | |
| 362 | def sub(num): |
| 363 | for i in range(10): |
| 364 | cvar.set(num + i) |
| 365 | time.sleep(random.uniform(0.001, 0.05)) |
| 366 | self.assertEqual(cvar.get(), num + i) |
| 367 | return num |
| 368 | |
| 369 | tp = concurrent.futures.ThreadPoolExecutor(max_workers=10) |
| 370 | try: |
| 371 | results = list(tp.map(sub, range(10))) |
| 372 | finally: |
| 373 | tp.shutdown() |
| 374 | self.assertEqual(results, list(range(10))) |
| 375 | |
| 376 | |
| 377 | # HAMT Tests |
nothing calls this directly
no test coverage detected