Skip to content

Commit

Permalink
style: bump flake8-pytest-style
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsnastins committed Jul 16, 2024
1 parent 910fd92 commit b2a5147
Show file tree
Hide file tree
Showing 45 changed files with 105 additions and 116 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def tomodachi_container(testcontainer_image: str) -> Generator[DockerContainer,
yield container


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_hello_testcontainers(tomodachi_container: TomodachiContainer) -> None:
async with httpx.AsyncClient(base_url=tomodachi_container.get_external_url()) as client:
response = await client.get("/hello", params={"name": "Testcontainers"})
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/debugging-testcontainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import httpx
import pytest


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_healthcheck_passes(http_client: httpx.AsyncClient) -> None:
response = await http_client.get("/health")

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/testing-databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ from tomodachi_testcontainers import PostgreSQLContainer

from my_project import create_app

@pytest.fixture()
@pytest.fixture
def app(monkeypatch: pytest.MonkeyPatch, postgres_container: PostgreSQLContainer) -> Flask:
monkeypatch.setenv("DATABASE_URL", str(postgres_container.get_external_url()))
return create_app()
Expand Down
2 changes: 1 addition & 1 deletion docs_src/getting_started/customers/test_app001.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


@pytest.mark.xfail(reason="CustomerCreatedEvent is emitted asynchronously")
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_created_event_emitted(
http_client: httpx.AsyncClient,
localstack_snssqs_tc: SNSSQSTestClient,
Expand Down
2 changes: 1 addition & 1 deletion docs_src/getting_started/customers/test_app002.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from tomodachi_testcontainers.clients import SNSSQSTestClient


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_created_event_emitted(
http_client: httpx.AsyncClient,
localstack_snssqs_tc: SNSSQSTestClient,
Expand Down
2 changes: 1 addition & 1 deletion docs_src/getting_started/customers/test_app003.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from tomodachi_testcontainers.clients import SNSSQSTestClient


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_created_event_emitted(
http_client: httpx.AsyncClient,
localstack_snssqs_tc: SNSSQSTestClient,
Expand Down
2 changes: 1 addition & 1 deletion docs_src/getting_started/customers/test_app004.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from tomodachi_testcontainers.clients import SNSSQSTestClient


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_register_created_order(
http_client: httpx.AsyncClient,
localstack_snssqs_tc: SNSSQSTestClient,
Expand Down
2 changes: 1 addition & 1 deletion docs_src/getting_started/customers/test_app005.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@pytest.mark.usefixtures("tomodachi_container")
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_not_found_for_newly_created_order(localstack_snssqs_tc: SNSSQSTestClient) -> None:
# Arrange
customer_id = str(uuid.uuid4())
Expand Down
4 changes: 2 additions & 2 deletions docs_src/getting_started/customers/test_app006.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_not_found(http_client: httpx.AsyncClient) -> None:
customer_id = uuid.uuid4()
response = await http_client.get(f"/customer/{customer_id}")
Expand All @@ -14,7 +14,7 @@ async def test_customer_not_found(http_client: httpx.AsyncClient) -> None:
assert response.json() == {"error": "CUSTOMER_NOT_FOUND"}


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_created_and_get_customer(http_client: httpx.AsyncClient) -> None:
response = await http_client.post("/customer", json={"name": "John Doe"})
body = response.json()
Expand Down
4 changes: 2 additions & 2 deletions docs_src/getting_started/hello/test_app001.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tomodachi_testcontainers import TomodachiContainer


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_hello_testcontainers(tomodachi_container: TomodachiContainer) -> None:
async with httpx.AsyncClient(base_url=tomodachi_container.get_external_url()) as client:
response = await client.get("/hello", params={"name": "Testcontainers"})
Expand All @@ -18,7 +18,7 @@ async def test_hello_testcontainers(tomodachi_container: TomodachiContainer) ->


# --8<-- [start:test_hello_world]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_hello_world(tomodachi_container: TomodachiContainer) -> None:
async with httpx.AsyncClient(base_url=tomodachi_container.get_external_url()) as client:
response = await client.get("/hello")
Expand Down
4 changes: 2 additions & 2 deletions docs_src/getting_started/hello/test_app002.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import pytest


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_hello_testcontainers(http_client: httpx.AsyncClient) -> None:
response = await http_client.get("/hello", params={"name": "Testcontainers"})

assert response.status_code == 200
assert response.json() == {"message": "Hello, Testcontainers!"}


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_hello_world(http_client: httpx.AsyncClient) -> None:
response = await http_client.get("/hello")

Expand Down
6 changes: 3 additions & 3 deletions docs_src/getting_started/orders/test_app001.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import wiremock.client as wm


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_order_created_when_credit_check_passed(http_client: httpx.AsyncClient) -> None:
mapping = wm.Mapping(
request=wm.MappingRequest(
Expand Down Expand Up @@ -38,7 +38,7 @@ async def test_order_created_when_credit_check_passed(http_client: httpx.AsyncCl


# --8<-- [start:test_order_not_created_when_credit_check_failed]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_order_not_created_when_credit_check_failed(http_client: httpx.AsyncClient) -> None:
mapping = wm.Mapping(
request=wm.MappingRequest(
Expand Down Expand Up @@ -66,7 +66,7 @@ async def test_order_not_created_when_credit_check_failed(http_client: httpx.Asy


# --8<-- [start:test_order_not_created_when_credit_check_service_unavailable]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_order_not_created_when_credit_check_service_unavailable(http_client: httpx.AsyncClient) -> None:
mapping = wm.Mapping(
request=wm.MappingRequest(method=wm.HttpMethods.POST, url="/credit-check"),
Expand Down
6 changes: 3 additions & 3 deletions docs_src/getting_started/orders/test_app002.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pytestmark = pytest.mark.usefixtures("reset_wiremock_container_on_teardown")


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_order_created_when_credit_check_passed(http_client: httpx.AsyncClient) -> None:
customer_id = "123456"
credit_check_mocks.customer_credit_check_passes(customer_id)
Expand All @@ -26,7 +26,7 @@ async def test_order_created_when_credit_check_passed(http_client: httpx.AsyncCl
}


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_order_not_created_when_credit_check_failed(http_client: httpx.AsyncClient) -> None:
customer_id = "123456"
credit_check_mocks.customer_credit_check_fails(customer_id)
Expand All @@ -40,7 +40,7 @@ async def test_order_not_created_when_credit_check_failed(http_client: httpx.Asy
assert response.json() == {"error": "CREDIT_CHECK_FAILED"}


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_order_not_created_when_credit_check_service_unavailable(http_client: httpx.AsyncClient) -> None:
credit_check_mocks.customer_credit_check_returns_internal_server_error()

Expand Down
2 changes: 1 addition & 1 deletion docs_src/getting_started/s3/test_app001.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from types_aiobotocore_s3 import S3Client


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_save_file(http_client: httpx.AsyncClient, localstack_s3_client: S3Client) -> None:
await localstack_s3_client.create_bucket(Bucket="autotest-my-bucket")

Expand Down
2 changes: 1 addition & 1 deletion docs_src/getting_started/s3/test_app002.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from types_aiobotocore_s3 import S3Client


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_save_file(http_client: httpx.AsyncClient, localstack_s3_client: S3Client) -> None:
await localstack_s3_client.create_bucket(Bucket="autotest-my-bucket")

Expand Down
2 changes: 1 addition & 1 deletion docs_src/getting_started/s3/test_app003.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from types_aiobotocore_s3 import S3Client


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_save_and_get_file(http_client: httpx.AsyncClient, localstack_s3_client: S3Client) -> None:
await localstack_s3_client.create_bucket(Bucket="autotest-my-bucket")

Expand Down
4 changes: 2 additions & 2 deletions docs_src/getting_started/s3/test_app004.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def tomodachi_container(
import pytest


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_save_and_get_file(http_client: httpx.AsyncClient) -> None:
response = await http_client.post("/file/", json={"filename": "test.txt", "content": "Hello, world!"})
assert response.status_code == 200
Expand All @@ -57,7 +57,7 @@ async def test_save_and_get_file(http_client: httpx.AsyncClient) -> None:


# --8<-- [start:test_file_not_found]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_file_not_found(http_client: httpx.AsyncClient) -> None:
response = await http_client.get("/file/not-exists.txt")

Expand Down
2 changes: 1 addition & 1 deletion docs_src/readme/test_hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def tomodachi_container(testcontainer_image: str) -> Generator[DockerContainer,
yield container


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_hello_testcontainers(tomodachi_container: TomodachiContainer) -> None:
async with httpx.AsyncClient(base_url=tomodachi_container.get_external_url()) as client:
response = await client.get("/hello", params={"name": "Testcontainers"})
Expand Down
2 changes: 1 addition & 1 deletion docs_src/testing_repositories/test_repository001.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def repository(moto_dynamodb_client: DynamoDBClient) -> AsyncGenerator[Dyn
await moto_dynamodb_client.delete_table(TableName=table_name)


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_save_customer(repository: DynamoDBCustomerRepository) -> None:
# Arrange
customer = Customer.create(name="John Doe", email="[email protected]")
Expand Down
2 changes: 1 addition & 1 deletion docs_src/testing_repositories/test_repository002.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def repository(moto_dynamodb_client: DynamoDBClient) -> AsyncGenerator[Dyn


# --8<-- [start:tests]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_save_customer(repository: DynamoDBCustomerRepository, moto_dynamodb_client: DynamoDBClient) -> None:
# Arrange
customer = Customer.create(name="John Doe", email="[email protected]")
Expand Down
2 changes: 1 addition & 1 deletion docs_src/testing_repositories/test_repository003.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def repository(moto_dynamodb_client: DynamoDBClient) -> AsyncGenerator[Dyn


# --8<-- [start:tests]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_save_customer(repository: DynamoDBCustomerRepository) -> None:
# Arrange
customer = Customer.create(name="John Doe", email="[email protected]")
Expand Down
2 changes: 1 addition & 1 deletion docs_src/testing_repositories/test_repository004.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def repository(moto_dynamodb_client: DynamoDBClient) -> AsyncGenerator[Dyn


# --8<-- [start:tests]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_not_found(repository: DynamoDBCustomerRepository) -> None:
with pytest.raises(KeyError):
await repository.get("123456")
Expand Down
2 changes: 1 addition & 1 deletion docs_src/testing_repositories/test_repository005.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def repository(moto_dynamodb_client: DynamoDBClient) -> AsyncGenerator[Dyn


# --8<-- [start:tests]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_not_found(repository: DynamoDBCustomerRepository) -> None:
with pytest.raises(CustomerNotFoundError):
await repository.get("123456")
Expand Down
10 changes: 5 additions & 5 deletions docs_src/testing_repositories/test_repository006.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def dynamodb_repository(moto_dynamodb_client: DynamoDBClient) -> AsyncGene
await moto_dynamodb_client.delete_table(TableName=table_name)


@pytest.fixture()
@pytest.fixture
def fake_repository() -> InMemoryRepository:
return InMemoryRepository([])

Expand All @@ -48,7 +48,7 @@ def repository(


# --8<-- [start:tests]
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_save_customer(repository: CustomerRepository) -> None:
customer = Customer.create(name="John Doe", email="[email protected]")

Expand All @@ -57,13 +57,13 @@ async def test_save_customer(repository: CustomerRepository) -> None:
assert await repository.get(customer.id) == customer


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_not_found(repository: CustomerRepository) -> None:
with pytest.raises(CustomerNotFoundError, match="123456"):
await repository.get("123456")


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_id_should_be_unique(repository: CustomerRepository) -> None:
customer_id = str(uuid.uuid4())
customer_1 = Customer(id=customer_id, name="John Doe", email="[email protected]")
Expand All @@ -74,7 +74,7 @@ async def test_customer_id_should_be_unique(repository: CustomerRepository) -> N
await repository.save(customer_2)


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_customer_email_should_be_unique(repository: CustomerRepository) -> None:
customer_1 = Customer.create(name="John Doe", email="[email protected]")
customer_2 = Customer.create(name="John Doe", email="[email protected]")
Expand Down
21 changes: 5 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ flake8-junit-report = "^2.1.0"
flake8-literal = "^1.3.0"
flake8-no-pep420 = "^2.7.0"
flake8-pyproject = "^1.2.3"
flake8-pytest-style = "^1.7.2"
flake8-pytest-style = "^2.0.0"
flake8-return = "^1.2.0"
flake8-simplify = "^0.21.0"
httpx = ">=0.25,<0.28"
Expand Down
Loading

0 comments on commit b2a5147

Please sign in to comment.