From 94e7b49e26f0e7cb4b7823764066fa7a62b09200 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ruziev <32102033+bruziev@users.noreply.github.com> Date: Sat, 19 Jan 2019 14:36:49 +0300 Subject: [PATCH] Replace tmpdir fixture with tmp_path in tests (#3551) (#3553) --- tests/conftest.py | 13 ------------- tests/test_connector.py | 4 ++-- tests/test_run_app.py | 8 ++++---- tests/test_web_runner.py | 4 ++-- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index c390430f3e9..755af857b83 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,6 @@ import hashlib -import pathlib import platform -import shutil import ssl -import tempfile import pytest import trustme @@ -11,16 +8,6 @@ pytest_plugins = ['aiohttp.pytest_plugin', 'pytester'] -@pytest.fixture -def shorttmpdir(): - """Provides a temporary directory with a shorter file system path than the - tmpdir fixture. - """ - tmpdir = pathlib.Path(tempfile.mkdtemp()) - yield tmpdir - shutil.rmtree(tmpdir, ignore_errors=True) - - @pytest.fixture def tls_certificate_authority(): if (platform.system() == 'Linux' and diff --git a/tests/test_connector.py b/tests/test_connector.py index 0e80efa0515..5a978860e42 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -43,8 +43,8 @@ def ssl_key(): @pytest.fixture -def unix_sockname(shorttmpdir): - sock_path = shorttmpdir / 'socket.sock' +def unix_sockname(tmpdir): + sock_path = tmpdir / 'socket.sock' return str(sock_path) diff --git a/tests/test_run_app.py b/tests/test_run_app.py index 99ee1a045ef..1086c177dd8 100644 --- a/tests/test_run_app.py +++ b/tests/test_run_app.py @@ -353,10 +353,10 @@ def test_run_app_custom_backlog_unix(patched_loop) -> None: @skip_if_no_unix_socks -def test_run_app_http_unix_socket(patched_loop, shorttmpdir) -> None: +def test_run_app_http_unix_socket(patched_loop, tmpdir) -> None: app = web.Application() - sock_path = str(shorttmpdir / 'socket.sock') + sock_path = str(tmpdir / 'socket.sock') printer = mock.Mock(wraps=stopper(patched_loop)) web.run_app(app, path=sock_path, print=printer) @@ -366,10 +366,10 @@ def test_run_app_http_unix_socket(patched_loop, shorttmpdir) -> None: @skip_if_no_unix_socks -def test_run_app_https_unix_socket(patched_loop, shorttmpdir) -> None: +def test_run_app_https_unix_socket(patched_loop, tmpdir) -> None: app = web.Application() - sock_path = str(shorttmpdir / 'socket.sock') + sock_path = str(tmpdir / 'socket.sock') ssl_context = ssl.create_default_context() printer = mock.Mock(wraps=stopper(patched_loop)) web.run_app(app, path=sock_path, ssl_context=ssl_context, print=printer) diff --git a/tests/test_web_runner.py b/tests/test_web_runner.py index 3b76b7af21c..6a94ae1df82 100644 --- a/tests/test_web_runner.py +++ b/tests/test_web_runner.py @@ -102,13 +102,13 @@ def test_non_app() -> None: @pytest.mark.skipif(platform.system() == "Windows", reason="Unix socket support is required") -async def test_addresses(make_runner, shorttmpdir) -> None: +async def test_addresses(make_runner, tmpdir) -> None: _sock = get_unused_port_socket('127.0.0.1') runner = make_runner() await runner.setup() tcp = web.SockSite(runner, _sock) await tcp.start() - path = str(shorttmpdir / 'tmp.sock') + path = str(tmpdir / 'tmp.sock') unix = web.UnixSite(runner, path) await unix.start() actual_addrs = runner.addresses