remove Python 3.5 bits from a test

Tests are tried with Python 2.7 as well, remove Python 3.5 concurrent
keywords from the specific test.
Forwarded: no
Last-Update: 2018-03-24

Gbp-Pq: Name de-Python3.5_tests.patch
This commit is contained in:
Laszlo Boszormenyi (GCS) 2022-07-18 20:29:18 +08:00 committed by Lu zhiping
parent 9ebbbe466f
commit 2343dfba4f
1 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,7 @@
"""Contains test functions using Python 3.3+ syntax."""
from asyncio import CancelledError
import sys
if (sys.version_info > (3, 5)):
from asyncio import CancelledError
from datetime import datetime
import pytest
@ -42,8 +44,8 @@ def tornado_executor(tornado_scheduler):
executor.shutdown()
async def waiter(sleep, exception):
await sleep(0.1)
def waiter(sleep, exception):
sleep(0.1)
if exception:
raise Exception('dummy error')
else:
@ -52,7 +54,7 @@ async def waiter(sleep, exception):
@pytest.mark.parametrize('exception', [False, True])
@pytest.mark.asyncio
async def test_run_coroutine_job(asyncio_scheduler, asyncio_executor, exception):
def test_run_coroutine_job(asyncio_scheduler, asyncio_executor, exception):
from asyncio import Future, sleep
future = Future()
@ -60,7 +62,7 @@ async def test_run_coroutine_job(asyncio_scheduler, asyncio_executor, exception)
asyncio_executor._run_job_success = lambda job_id, events: future.set_result(events)
asyncio_executor._run_job_error = lambda job_id, exc, tb: future.set_exception(exc)
asyncio_executor.submit_job(job, [datetime.now(utc)])
events = await future
events = future
assert len(events) == 1
if exception:
assert str(events[0].exception) == 'dummy error'
@ -70,7 +72,7 @@ async def test_run_coroutine_job(asyncio_scheduler, asyncio_executor, exception)
@pytest.mark.parametrize('exception', [False, True])
@pytest.mark.gen_test
async def test_run_coroutine_job_tornado(tornado_scheduler, tornado_executor, exception):
def test_run_coroutine_job_tornado(tornado_scheduler, tornado_executor, exception):
from tornado.concurrent import Future
from tornado.gen import sleep
@ -79,7 +81,7 @@ async def test_run_coroutine_job_tornado(tornado_scheduler, tornado_executor, ex
tornado_executor._run_job_success = lambda job_id, events: future.set_result(events)
tornado_executor._run_job_error = lambda job_id, exc, tb: future.set_exception(exc)
tornado_executor.submit_job(job, [datetime.now(utc)])
events = await future
events = future
assert len(events) == 1
if exception:
assert str(events[0].exception) == 'dummy error'
@ -88,7 +90,7 @@ async def test_run_coroutine_job_tornado(tornado_scheduler, tornado_executor, ex
@pytest.mark.asyncio
async def test_asyncio_executor_shutdown(asyncio_scheduler, asyncio_executor):
def test_asyncio_executor_shutdown(asyncio_scheduler, asyncio_executor):
"""Test that the AsyncIO executor cancels its pending tasks on shutdown."""
from asyncio import sleep
@ -99,4 +101,4 @@ async def test_asyncio_executor_shutdown(asyncio_scheduler, asyncio_executor):
asyncio_executor.shutdown()
with pytest.raises(CancelledError):
await futures.pop()
futures.pop()