Skip to content

Commit

Permalink
added pytest-random-order plugin + use randomization in the test comm…
Browse files Browse the repository at this point in the history
…and + added cleanup to service tests
  • Loading branch information
volfpeter committed Aug 6, 2023
1 parent 29fde61 commit 2f46b3d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
16 changes: 15 additions & 1 deletion poetry.lock

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

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ poethepoet = "^0.21.1"
pytest = "^7.4.0"
pytest-asyncio = "^0.21.1"
pytest-docker = "^2.0.0"
pytest-random-order = "^1.1.0"

[tool.poetry.group.fastapi.dependencies]
fastapi = {extras = ["all"], version = "^0.100.1"}
Expand Down Expand Up @@ -107,7 +108,7 @@ black = "black ."
black-check = "black . --check"
mypy = "mypy ."
ruff = "ruff check ."
test = "python -m pytest tests"
test = "python -m pytest tests --random-order"

static-checks.sequence = ["ruff", "black-check", "mypy"]
static-checks.ignore_fail = "return_non_zero"
Expand Down
6 changes: 6 additions & 0 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ async def test_create(self, *, person_service: PersonService) -> None:
p = Person(**result)
assert isinstance(p.id, ObjectId)

delete_result = await person_service.delete_by_id(p.id)
assert delete_result.deleted_count == 1

@pytest.mark.asyncio
async def test_insert_one(self, *, person_service: PersonService) -> None:
pd = PersonData(name="Jack", lucky_number=6)
Expand All @@ -53,3 +56,6 @@ async def test_insert_one(self, *, person_service: PersonService) -> None:

p = Person(**result)
assert isinstance(p.id, ObjectId)

delete_result = await person_service.delete_by_id(p.id)
assert delete_result.deleted_count == 1

0 comments on commit 2f46b3d

Please sign in to comment.