Skip to content

use explicit assertions following Python idioms#2013

Merged
iMicknl merged 5 commits intov2/mainfrom
v2/test_refactor
Apr 24, 2026
Merged

use explicit assertions following Python idioms#2013
iMicknl merged 5 commits intov2/mainfrom
v2/test_refactor

Conversation

@iMicknl
Copy link
Copy Markdown
Owner

@iMicknl iMicknl commented Apr 24, 2026

Apply feedback from #1916

iMicknl added 3 commits April 24, 2026 13:54
…conftest.py

Centralizes reusable test infrastructure in a shared conftest module,
removing duplication from test_client.py and adding type hints.
Replace `assert x` / `assert not x` with `assert x is not None` /
`assert x is None` where the intent is to check for None, not falsiness.
Replace `assert state.value_as_X` inside `pytest.raises()` blocks with
`_ = state.value_as_X` to avoid misleading assert-inside-raises and
satisfy B018 (useless expression) lint rule.
@iMicknl iMicknl requested a review from tetienne as a code owner April 24, 2026 13:57
Copilot AI review requested due to automatic review settings April 24, 2026 13:57
@iMicknl iMicknl added enhancement New feature or request v2 labels Apr 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the test suite to use more explicit, idiomatic Python assertions and consolidates shared test utilities/fixtures to align with feedback from #1916.

Changes:

  • Replace truthiness-based assertions with explicit is None / is not None checks in multiple tests.
  • Move shared test helpers/fixtures (e.g., MockResponse, client, local_client) into tests/conftest.py.
  • Adjust exception tests to explicitly trigger property access inside pytest.raises(...).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tests/test_utils.py Switches local server config assertions to explicit is not None.
tests/test_models.py Uses explicit None/non-None assertions and simplifies exception assertions.
tests/test_client.py Removes inline fixtures and uses shared MockResponse; makes assertions more explicit.
tests/conftest.py Adds shared MockResponse helper and async client/local_client fixtures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_client.py Outdated
Comment thread tests/conftest.py
Comment thread tests/test_client.py Outdated
Comment thread tests/conftest.py Outdated
@iMicknl iMicknl merged commit 389569c into v2/main Apr 24, 2026
6 checks passed
@iMicknl iMicknl deleted the v2/test_refactor branch April 24, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants