Skip to content
Snippets Groups Projects
Commit 12fa6f26 authored by Tenma's avatar Tenma
Browse files

core tests: disambiguate arg 'request' through typing

Both requests.Request and _pytest.FixtureRequest objects are passed to
test fixtures as argument 'request'. This hurts readability.
Adding typing annotations makes it clear which one is meant.
parent 74544839
No related branches found
No related tags found
1 merge request!185core tests: disambiguate arg 'request' through typing
......@@ -8,6 +8,7 @@ import logging
import subprocess
from typing import Optional, Set, Union
from _pytest.fixtures import FixtureRequest
import psycopg2
import pytest
from pytest_postgresql import factories
......@@ -137,7 +138,7 @@ def postgresql_fact(
no_truncate_tables: Set[str] = {"dbversion"},
):
@pytest.fixture
def postgresql_factory(request):
def postgresql_factory(request: FixtureRequest):
"""Fixture factory for PostgreSQL.
:param FixtureRequest request: fixture request object
......
......@@ -10,6 +10,7 @@ import re
from typing import Dict, List, Optional
from urllib.parse import unquote, urlparse
from _pytest.fixtures import FixtureRequest
import pytest
import requests
from requests.adapters import BaseAdapter
......@@ -117,7 +118,7 @@ def get_response_cb(
@pytest.fixture
def datadir(request):
def datadir(request: FixtureRequest) -> str:
"""By default, returns the test directory's data directory.
This can be overridden on a per file tree basis. Add an override
......@@ -297,7 +298,7 @@ def flask_app_client(app):
# stolen from pytest-flask, required to have url_for() working within tests
# using flask_app_client fixture.
@pytest.fixture(autouse=True)
def _push_request_context(request):
def _push_request_context(request: FixtureRequest):
"""During tests execution request context has been pushed, e.g. `url_for`,
`session`, etc. can be used in tests as is::
......
......@@ -16,7 +16,7 @@ pytest_v = pkg_resources.get_distribution("pytest").parsed_version
if pytest_v < pkg_resources.extern.packaging.version.parse("3.9"):
@pytest.fixture
def tmp_path(request):
def tmp_path():
import pathlib
import tempfile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment