From b5f69bfb7144236ac02077aafcf3518818d31af7 Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Mon, 12 Feb 2018 20:36:06 -0800 Subject: [PATCH 1/5] Make test robust against py37 change in RuntimeError.__repr__ On Python 3.6: >>> RuntimeError("oops") RuntimeError('oops',) On Python 3.7-dev: >>> RuntimeError("oops") RuntimeError('oops') --- trio/_core/tests/test_result.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/_core/tests/test_result.py b/trio/_core/tests/test_result.py index 4924178437..9d6cdd8f38 100644 --- a/trio/_core/tests/test_result.py +++ b/trio/_core/tests/test_result.py @@ -17,7 +17,7 @@ def test_Result(): assert e.error is exc with pytest.raises(RuntimeError): e.unwrap() - assert repr(e) == "Error(RuntimeError('oops',))" + assert repr(e) == "Error({!r})".format(exc) with pytest.raises(TypeError): Error("hello") From c25388fa29e7d246781ce7a4d293526a053a0932 Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Mon, 12 Feb 2018 20:40:05 -0800 Subject: [PATCH 2/5] Adjust asyncio error tests for changes in 3.7-dev We want to test how Trio handles a function decorated with @asyncio.coroutine. Previously we did this by using asyncio.sleep. But in Python 3.7, asyncio.sleep has become an async def function instead, so the test failed. Now we define our own function decorated with @asyncio.coroutine and test that, instead of making assumptions about the stdlib. --- trio/_core/_run.py | 4 ++-- trio/_core/tests/test_run.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/trio/_core/_run.py b/trio/_core/_run.py index ca1f0a9440..1f52b02d15 100644 --- a/trio/_core/_run.py +++ b/trio/_core/_run.py @@ -768,7 +768,7 @@ def _return_value_looks_like_wrong_library(value): .format(async_fn=async_fn) ) from None - # Give good error for: nursery.start_soon(asyncio.sleep(1)) + # Give good error for: nursery.start_soon(future) if _return_value_looks_like_wrong_library(async_fn): raise TypeError( "trio was expecting an async function, but instead it got " @@ -785,7 +785,7 @@ def _return_value_looks_like_wrong_library(value): # function. So we have to just call it and then check whether the # result is a coroutine object. if not inspect.iscoroutine(coro): - # Give good error for: nursery.start_soon(asyncio.sleep, 1) + # Give good error for: nursery.start_soon(func_returning_future) if _return_value_looks_like_wrong_library(coro): raise TypeError( "start_soon got unexpected {!r} – are you trying to use a " diff --git a/trio/_core/tests/test_run.py b/trio/_core/tests/test_run.py index ce05f500c1..08e07f6359 100644 --- a/trio/_core/tests/test_run.py +++ b/trio/_core/tests/test_run.py @@ -1553,8 +1553,12 @@ async def f(): # pragma: no cover import asyncio + @asyncio.coroutine + def generator_based_coro(): + yield from asyncio.sleep(1) + with pytest.raises(TypeError) as excinfo: - bad_call(asyncio.sleep(1)) + bad_call(generator_based_coro()) assert "asyncio" in str(excinfo.value) with pytest.raises(TypeError) as excinfo: @@ -1562,7 +1566,7 @@ async def f(): # pragma: no cover assert "asyncio" in str(excinfo.value) with pytest.raises(TypeError) as excinfo: - bad_call(asyncio.sleep, 1) + bad_call(generator_based_coro) assert "asyncio" in str(excinfo.value) with pytest.raises(TypeError) as excinfo: From 05647c6b3e7fdf3831d4d73efe743d57611394d8 Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Mon, 12 Feb 2018 20:50:15 -0800 Subject: [PATCH 3/5] [travis] Fix pypy skipping logic We were calling 'exit 0' to skip the tests... inside subshell parentheses (), so it was only exiting the subshell, not the overall script. Whoops. Fix that. --- ci/travis.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ci/travis.sh b/ci/travis.sh index b87cb32e96..7481deae82 100755 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -24,10 +24,13 @@ if [ "$USE_PYPY_NIGHTLY" = "1" ]; then # something like "pypy-c-jit-89963-748aa3022295-linux64" PYPY_DIR=$(echo pypy-c-jit-*) PYTHON_EXE=$PYPY_DIR/bin/pypy3 - ($PYTHON_EXE -m ensurepip \ - && $PYTHON_EXE -m pip install virtualenv \ - && $PYTHON_EXE -m virtualenv testenv) \ - || (echo "pypy nightly is broken; skipping tests"; exit 0) + + if ! ($PYTHON_EXE -m ensurepip \ + && $PYTHON_EXE -m pip install virtualenv \ + && $PYTHON_EXE -m virtualenv testenv); then + echo "pypy nightly is broken; skipping tests" + exit 0 + fi source testenv/bin/activate fi From babb8439248f08f59ce5de085ac57c7bbee79830 Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Mon, 12 Feb 2018 21:27:04 -0800 Subject: [PATCH 4/5] Pin Sphinx version at <1.7.0 https://github.com/sphinx-doc/sphinx/issues/4609 --- ci/rtd-requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/rtd-requirements.txt b/ci/rtd-requirements.txt index 67898ba6f5..4f07be4ab8 100644 --- a/ci/rtd-requirements.txt +++ b/ci/rtd-requirements.txt @@ -1,4 +1,5 @@ # RTD is currently installing 1.5.3, which has a bug in :lineno-match: -sphinx >= 1.6.1 +# 1.7.0 hits https://github.com/sphinx-doc/sphinx/issues/4609 +sphinx == 1.6.7 sphinx_rtd_theme sphinxcontrib-trio From 614b5e3e5ed289f5d94bf9cd2781ec49d67aa44c Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Mon, 12 Feb 2018 21:39:57 -0800 Subject: [PATCH 5/5] Coverage fix --- trio/_core/tests/test_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/_core/tests/test_run.py b/trio/_core/tests/test_run.py index 08e07f6359..02e4d198ae 100644 --- a/trio/_core/tests/test_run.py +++ b/trio/_core/tests/test_run.py @@ -1554,7 +1554,7 @@ async def f(): # pragma: no cover import asyncio @asyncio.coroutine - def generator_based_coro(): + def generator_based_coro(): # pragma: no cover yield from asyncio.sleep(1) with pytest.raises(TypeError) as excinfo: