▸case-01 I have a Python service using `httpx` for making asynchronous API calls to a third-party payment gateway. I need help writing a pytest suite that mocks these external network requests using fixtures. Could you provide a clean test module code example along with step-by-step instructions for running and verifying the tests? | fail→fail | 22,864 | 23,017 | +1% | 1 | 1 | 0% | 3,981 | 4,371 | +10% | 0 | 0 | — |
▸case-02 I am building a data repository layer in Python with SQLAlchemy and want to test several database validation edge cases. Can you show me how to write parameterized pytest functions that automatically roll back database changes after each test run, formatted as a code snippet with explanation steps? | fail→fail | 20,971 | 20,491 | -2% | 1 | 1 | 0% | 3,519 | 3,461 | -2% | 0 | 0 | — |
▸case-03 Our team has a bloated Python script testing a complex financial calculation module, and we want to refactor it using best practices like reusable fixtures and Hypothesis for property testing. Please generate a guide containing code blocks for the refactored test setup and a verification checklist for CI execution. | fail→fail | 27,632 | 23,567 | -15% | 1 | 1 | 0% | 4,585 | 4,056 | -12% | 0 | 0 | — |
▸case-04 I need to design a FastAPI application directory layout and database model schema for an e-commerce order service. Please provide the folder structure and SQLAlchemy model definitions. | pass→pass | 28,494 | 22,759 | -20% | 1 | 1 | 0% | 4,061 | 4,210 | +4% | 0 | 0 | — |
▸case-05 We are preparing to deploy a Python web application using Gunicorn. Please write a multi-stage Dockerfile optimized for small image size and production security. | pass→pass | 15,441 | 17,298 | +12% | 1 | 1 | 0% | 2,963 | 3,850 | +30% | 0 | 0 | — |
▸case-06 Our production Python service is experiencing high latency under load. Can you show how to profile memory allocations and CPU execution using tracemalloc and cProfile? | pass→pass | 16,164 | 18,291 | +13% | 1 | 1 | 0% | 3,075 | 2,988 | -3% | 0 | 0 | — |
▸case-07 We are setting up a test suite for a Python database package. Instead of re-opening a database connection for every single unit test function, we want to optimize connection overhead. Should we use function-scoped fixtures or session-scoped fixtures for expensive database engine instantiation? Provide the code and verification. | fail→fail | 19,335 | 11,731 | -39% | 1 | 1 | 0% | 2,604 | 2,498 | -4% | 0 | 0 | — |
▸case-08 I am testing a Python utility function that reads configuration files from disk. I want to avoid writing temporary files to disk during unit tests. Should I use unittest.mock.mock_open or create real temp files via tempfile? Please show the mocking approach. | fail→fail | 18,266 | 16,389 | -10% | 1 | 1 | 0% | 2,574 | 2,465 | -4% | 0 | 0 | — |
▸case-09 I have async functions in Python that need unit tests. Should I create custom event loops manually inside each test function, or use a specialized pytest marker? Show the implementation pattern. | fail→fail | 10,526 | 10,403 | -1% | 1 | 1 | 0% | 2,122 | 2,363 | +11% | 0 | 0 | — |
▸case-10 We are testing a validation function that accepts integers between 1 and 100. Instead of writing 10 separate test functions for edge cases like 0, 1, 50, 100, and 101, how should we structure this cleanly? | fail→fail | 11,305 | 13,704 | +21% | 1 | 1 | 0% | 2,203 | 2,046 | -7% | 0 | 0 | — |
▸case-11 My Python service reads API credentials from environment variables using os.environ. How can I safely override these environment variables during unit tests without corrupting the host machine environment? | fail→fail | 11,663 | 9,712 | -17% | 1 | 1 | 0% | 2,099 | 2,218 | +6% | 0 | 0 | — |
▸case-12 I want to verify that calling my payment processing function with a negative amount raises a custom ValueError containing the text 'Invalid amount'. How should I assert this in pytest? | fail→fail | 11,195 | 10,126 | -10% | 1 | 1 | 0% | 1,236 | 1,176 | -5% | 0 | 0 | — |
▸case-13 We have a global logging configuration that needs to reset its state before every single test in the repository. How can we ensure a setup fixture runs automatically without manually referencing it in every test signature? | fail→fail | 9,091 | 12,363 | +36% | 1 | 1 | 0% | 1,592 | 1,590 | -0% | 0 | 0 | — |
▸case-14 I need to test a function that writes output logs to a directory on disk. Should I hardcode a '/tmp/test_output' path or use built-in pytest path fixtures? | fail→fail | 8,560 | 12,610 | +47% | 1 | 1 | 0% | 1,726 | 1,745 | +1% | 0 | 0 | — |
▸case-15 We are testing a custom JSON sanitizer function in Python. Instead of manual example inputs, we want to generate hundreds of arbitrary unicode string inputs automatically. Which pattern should we use? | fail→fail | 16,324 | 13,360 | -18% | 1 | 1 | 0% | 2,075 | 1,782 | -14% | 0 | 0 | — |
▸case-16 A legacy Python command-line function prints status updates using print statements rather than returning a value. How can we capture and assert stdout output in pytest? | fail→fail | 14,506 | 13,513 | -7% | 1 | 1 | 0% | 1,730 | 1,944 | +12% | 0 | 0 | — |
▸case-17 Our subscription service calculates grace periods based on datetime.now(). Tests keep failing because time changes every run. How should we freeze or mock time reliably in pytest? | fail→fail | 18,505 | 13,783 | -26% | 1 | 1 | 0% | 2,506 | 2,968 | +18% | 0 | 0 | — |
▸case-18 We have docstrings with interactive Python code examples inside our utility module. How do we execute these docstrings automatically as part of our test suite? | fail→fail | 10,051 | 14,997 | +49% | 1 | 1 | 0% | 1,943 | 2,174 | +12% | 0 | 0 | — |
▸case-19 We want to separate fast unit tests from slow integration tests so CI can run fast tests on every commit. How do we mark slow tests and filter execution? | fail→fail | 20,033 | 10,020 | -50% | 1 | 1 | 0% | 2,898 | 2,254 | -22% | 0 | 0 | — |
▸case-20 How should we write unit tests that verify a Pydantic v2 model raises ValidationError when invalid field types are provided? | fail→fail | 14,504 | 17,006 | +17% | 1 | 1 | 0% | 2,871 | 2,678 | -7% | 0 | 0 | — |
▸case-21 Our unit test suite takes 15 minutes to run sequentially on 1000 test files. How can we execute tests concurrently across all CPU cores? | fail→fail | 17,542 | 18,375 | +5% | 1 | 1 | 0% | 2,250 | 2,673 | +19% | 0 | 0 | — |
▸case-22 We need to unit test a service that relies on an external gRPC client stub without connecting to a real gRPC network server. | fail→fail | 20,661 | 19,911 | -4% | 1 | 1 | 0% | 2,958 | 3,481 | +18% | 0 | 0 | — |