Skip to content

test: migrate to pytest#41

Merged
jy-tan merged 2 commits intomainfrom
use-pytest
Jan 16, 2026
Merged

test: migrate to pytest#41
jy-tan merged 2 commits intomainfrom
use-pytest

Conversation

@jy-tan
Copy link
Contributor

@jy-tan jy-tan commented Jan 16, 2026

Summary

Migrates the entire test suite from unittest.TestCase style to native pytest style for cleaner, more idiomatic tests.

  • Convert 17 test files (12 unit, 5 integration) from unittest.TestCase to pytest classes/functions
  • Replace unittest.mock.patch with pytest-mock's mocker fixture for automatic cleanup
  • Add shared fixtures in tests/conftest.py
  • Update CONTRIBUTING.md with pytest commands

Changes

Dependencies (pyproject.toml):

  • Add pytest-mock>=3.15.0
  • Pin pytest>=8.0.0,<9.0.0 (9.x requires Python 3.10+)

Test patterns converted:

  • self.assertEqual(a, b)assert a == b
  • self.assertIn(a, b)assert a in b
  • setUp/tearDown@pytest.fixture
  • setUpClass/tearDownClass@pytest.fixture(scope="module")
  • with patch(...) as mock:mock = mocker.patch(...)

Test plan

  • All 192 unit tests pass
  • Lint checks pass

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 21 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="tests/integration/test_flask_transforms.py">

<violation number="1" location="tests/integration/test_flask_transforms.py:34">
P2: `setup_transforms` is defined as a pytest fixture but never requested or marked `autouse`, so class-level setup won’t run. This breaks the previous `setUpClass` behavior once transforms are implemented.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@jy-tan jy-tan merged commit 4b4b1f3 into main Jan 16, 2026
6 checks passed
@jy-tan jy-tan deleted the use-pytest branch January 16, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants