Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes to coverage, type hints, documentation, and QoL for Makefile #1101

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ For example, using *virtualenvwrapper* commands could look like::

After that, please install libraries required for development::

$ pip install pip-tools
$ pip-compile requirements-dev.in
$ pip-sync requirements-dev.txt

Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Some simple testing tasks (sorry, UNIX only).

FLAGS=
# ?= conditional assign, so users can pass options on the CLI instead of manually editing this file
FLAGS?=

pre-commit flake: checkrst
pre-commit run --all
Expand All @@ -22,7 +23,7 @@ cov cover coverage: pre-commit
mototest:
docker pull alpine
docker pull lambci/lambda:python3.8
BOTO_CONFIG=/dev/null python -Wd -X tracemalloc=5 -X faulthandler -m pytest -vv -m moto -n auto --cov-report term --cov-report html --cov-report xml --cov=aiobotocore --cov=tests --log-cli-level=DEBUG aiobotocore tests
BOTO_CONFIG=/dev/null python -Wd -X tracemalloc=5 -X faulthandler -m pytest -vv -m moto -n auto --cov-report term --cov-report html --cov-report xml --cov=aiobotocore --cov=tests --log-cli-level=DEBUG $(FLAGS) aiobotocore tests
@echo "open file://`pwd`/htmlcov/index.html"

clean:
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@ secret accessible via environment variables:
::

$ pip install pip-tools
$ pip-compile requirements-dev.txt
$ pip-compile requirements-dev.in
$ pip-sync requirements-dev.txt
$ export AWS_ACCESS_KEY_ID=xxx
$ export AWS_SECRET_ACCESS_KEY=xxx
$ export AWS_DEFAULT_REGION=xxx # e.g. us-west-2

Execute tests suite:

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ src_paths = ["aiobotocore", "tests"]
[tool.black]
line-length = 79
skip_string_normalization = true

[tool.coverage.report]
exclude_also = [
"if TYPE_CHECKING",
]
29 changes: 12 additions & 17 deletions tests/boto_tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import itertools
import json
from typing import List, Tuple, Union
from typing import Iterator, Tuple, Union

import pytest
from botocore.exceptions import ReadTimeoutError
Expand All @@ -9,18 +11,17 @@
from aiobotocore import utils
from aiobotocore._helpers import asynccontextmanager

# TypeAlias (requires typing_extensions or >=3.10 to annotate)
Response = Tuple[Union[str, object], int]


# From class TestContainerMetadataFetcher
def fake_aiohttp_session(
responses: Union[
List[Tuple[Union[str, object], int]], Tuple[Union[str, object], int]
]
):
def fake_aiohttp_session(responses: list[Response] | Response):
thehesiod marked this conversation as resolved.
Show resolved Hide resolved
"""
Dodgy shim class
"""
if isinstance(responses, Tuple):
data = itertools.cycle([responses])
if isinstance(responses, tuple):
data: Iterator[Response] = itertools.cycle([responses])
else:
data = iter(responses)

Expand Down Expand Up @@ -83,9 +84,7 @@ async def test_idmsfetcher_disabled():
@pytest.mark.asyncio
async def test_idmsfetcher_get_token_success():
session = fake_aiohttp_session(
[
('blah', 200),
]
('blah', 200),
)

fetcher = utils.AioIMDSFetcher(
Expand All @@ -99,9 +98,7 @@ async def test_idmsfetcher_get_token_success():
@pytest.mark.asyncio
async def test_idmsfetcher_get_token_not_found():
session = fake_aiohttp_session(
[
('blah', 404),
]
('blah', 404),
)

fetcher = utils.AioIMDSFetcher(
Expand All @@ -115,9 +112,7 @@ async def test_idmsfetcher_get_token_not_found():
@pytest.mark.asyncio
async def test_idmsfetcher_get_token_bad_request():
session = fake_aiohttp_session(
[
('blah', 400),
]
('blah', 400),
)

fetcher = utils.AioIMDSFetcher(
Expand Down
Loading