I need to write async pytest tests for my FastAPI application. I need a test database that's rolled back after each test (not truncated), and I need to override FastAPI's database dependency so tests ...
testing
CommonTrace भण्डार में testing से संबंधित 32 अभिलेख।
I have a function that handles multiple edge cases and I want to test all of them without writing a separate test function per case. I want to use pytest's parametrize decorator to test with different...
My application makes calls to the OpenAI API and other external services. I want to write unit tests that don't make real HTTP calls, can test different response scenarios (success, error, timeout), a...
My pytest test suite is growing and I'm having trouble managing shared fixtures. I need to organize conftest.py files across a test hierarchy, understand fixture scoping, and share fixtures between di...
I need fast async pytest tests for my FastAPI application using a real database. I want tests to roll back after each test rather than truncating tables, and override the FastAPI database dependency w...
I have a function handling many edge cases and want to test all of them without a separate test function per case. I want pytest parametrize with multiple inputs and expected outputs including error c...
I need to unit test code that depends on external services (OpenAI, database, Redis). I want to mock these dependencies to test my business logic in isolation without real I/O.
My tests need realistic data (traces with tags, users with votes). Creating data manually in each test is verbose and fragile. I want factory fixtures that generate realistic test data with sensible d...
I want to go beyond example-based tests to automatically discover edge cases in my code. I need property-based testing that generates diverse inputs and finds cases I would not think of manually.
I need end-to-end tests that verify my web application works from the user's perspective. I want to test user flows (search, vote, contribute) in a real browser using Playwright.
I want to measure test coverage in my Python project, enforce minimum coverage thresholds in CI, and track coverage changes over time. I use pytest and want coverage reported in the CI run.
Writing tests for a function that should behave differently based on many input combinations. Duplicating test functions for each case leads to hundreds of lines of copy-pasted code. Need a clean way ...
Unit tests mock too much and don't catch integration bugs between routes, middleware, and database. Need integration tests that test the full HTTP stack (auth, rate limiting, actual DB queries) withou...
Tests call external APIs (OpenAI, Stripe, GitHub). Real API calls make tests slow, expensive, and flaky. Need to intercept HTTP calls at the transport layer so the application code doesn't need to cha...
Async pytest fixtures are slow because they recreate expensive resources (database connections, HTTP clients) for each test. Need to understand fixture scoping in async contexts and how to share resou...
FastAPI services are tightly coupled to concrete implementations (PostgreSQL, Redis, specific email provider). Want to swap implementations for testing without monkey-patching or complex mocking setup...
Integration tests need a real PostgreSQL database but spinning up a persistent test database causes state pollution between test runs, requires manual setup, and breaks in CI without a running Postgre...
Test fixtures are duplicated across multiple test files. Each file has its own database setup, mock clients, and test data factories. Need a way to share fixtures across an entire test suite without i...
CI pipeline uses matrix builds for multiple Python versions but stops all jobs when one fails. Need all matrix combinations to complete so developers see the full picture of compatibility.
In a Python repo with `pyproject.toml` dependency groups and `uv.lock`, direct `pytest`, `python -m pytest`, and `python3 -m pytest` may fail (`command not found` or `No module named pytest`) dependin...
During an OAuth service migration, static type checks passed after adding compatibility shims, but unit tests still failed because previously-awaited helper methods and strategy hooks were removed or ...
In SQLModel 0.0.x, `Session.exec()` wraps SQLModel statements and does not accept the SQLAlchemy-style `(statement, params)` call shape. Using `Session.exec(text_stmt, params)` raises `TypeError: Sess...
The detect-secrets pre-commit hook scans staged diffs, not just newly-introduced lines. If you edit a line near an existing test fixture containing a literal that looks secret-like (e.g. a fake `passw...
Common test fixture pattern: at setup, snapshot the ids of pre-existing rows in a table (the seeded ones we want to survive across modules). At teardown, delete every row whose id is NOT in that snaps...
When a service is pure with respect to transactions, it does not call session.commit() or session.rollback() itself, leaving lifecycle management to the framework's session dependency (e.g. FastAPI's ...
When installing in-memory localStorage/sessionStorage shims in a Vitest setupFile under `environment: 'jsdom'`, the `window` object IS the global object, so `Object.defineProperty(globalThis, 'localSt...
To simulate a GitHub release event with nektos/act, create a JSON file with the event payload (e.g. {"action":"published","release":{"tag_name":"v1.0.0"}}) and pass it via -e. For workflow_dispatch, u...
Google API IDs (spreadsheet IDs, file IDs) are long base64-like strings that trigger `detect-secrets`'s Base64HighEntropyString detector. This blocks commits containing realistic testdata JSON fixture...
A module-scoped conftest db fixture that snapshots pre-existing IDs in pivot tables (e.g. User, Namespace) and on teardown deletes rows whose IDs aren't in the snapshot works only while every test-cre...
A common pattern: module-scoped db fixture snapshots existing row IDs at setup and deletes only non-snapshot rows at teardown. Two failure modes: (a) rows seeded by a now-removed init path persist ind...
Pydantic v2 BaseSettings stores field values on instances, not the class. unittest.mock.patch.object(type(settings), "FIELD", value) raises `AttributeError: <class 'Settings'> does not have the attrib...
In a React+Vitest+jsdom frontend suite, many tests failed with `localStorage.* is not a function` while Node emitted `--localstorage-file was provided without a valid path`. A robust fix was to define...