Fix test incompatibility with PyPy3

This commit is contained in:
Nick Coghlan 2021-06-26 18:30:55 +10:00
parent 4b39470cbb
commit 032662d6e9
3 changed files with 13 additions and 7 deletions

View file

@ -1,2 +1,2 @@
include *.py *.txt *.rst *.md *.ini MANIFEST.in
recursive-include test docs *.rst *.py make.bat Makefile
recursive-include dev test docs *.rst *.py make.bat Makefile

View file

@ -9,6 +9,7 @@ from contextlib2 import * # Tests __all__
from test import support
from test.support import os_helper
import weakref
import gc
class TestAbstractContextManager(unittest.TestCase):
@ -228,6 +229,8 @@ def woohoo():
def woohoo(a, b):
a = weakref.ref(a)
b = weakref.ref(b)
# Allow test to work with a non-refcounted GC
gc.collect(); gc.collect(); gc.collect()
self.assertIsNone(a())
self.assertIsNone(b())
yield

View file

@ -1,7 +1,7 @@
import asyncio
from contextlib2 import (
asynccontextmanager, AbstractAsyncContextManager,
AsyncExitStack, nullcontext, aclosing)
AsyncExitStack, nullcontext, aclosing, contextmanager)
import functools
from test import support
import unittest
@ -346,14 +346,17 @@ class AclosingTestCase(unittest.TestCase):
async def test_aclosing_bpo41229(self):
state = []
class Resource:
def __del__(self):
@contextmanager
def sync_resource():
try:
yield
finally:
state.append(1)
async def agenfunc():
r = Resource()
yield -1
yield -2
with sync_resource():
yield -1
yield -2
x = agenfunc()
self.assertEqual(state, [])