|
1 | 1 | ## Running the tests |
2 | 2 |
|
3 | | -1. Run the tests |
| 3 | +1. Run all tests (excluding those requiring real DBs, see item 3): |
4 | 4 | ```bash |
5 | | - uv run pytest -v -s client/test_client_factory.py |
| 5 | + uv run pytest |
6 | 6 | ``` |
7 | 7 |
|
| 8 | + ``` |
| 9 | + |
| 10 | + **Useful Flags:** |
| 11 | + - `-v` (verbose): Shows more detailed output, including each test name as it runs. |
| 12 | + - `-s` (no capture): Allows stdout (print statements) to show in the console. Useful for debugging. |
| 13 | + |
| 14 | + Example with flags: |
| 15 | + ```bash |
| 16 | + uv run pytest -v -s |
| 17 | + ``` |
| 18 | + |
| 19 | + Note: Some tests require external databases (PostgreSQL, MySQL) and will be skipped if the corresponding environment variables (`POSTGRES_TEST_DSN`, `MYSQL_TEST_DSN`) are not set. |
| 20 | + |
| 21 | +2. Run specific tests: |
| 22 | + ```bash |
| 23 | + # Run a specific test file |
| 24 | + uv run pytest tests/client/test_client_factory.py |
| 25 | +
|
| 26 | + # Run a specific test function |
| 27 | + uv run pytest tests/client/test_client_factory.py::test_client_factory_connect_with_url |
| 28 | +
|
| 29 | + # Run tests in a specific folder |
| 30 | + uv run pytest tests/client/ |
| 31 | + ``` |
| 32 | + |
| 33 | +3. Run database integration tests (requires Docker): |
| 34 | + ```bash |
| 35 | + ./scripts/run_db_tests.sh |
| 36 | + ``` |
| 37 | + |
| 38 | + This script will: |
| 39 | + - Start PostgreSQL and MySQL containers using Docker Compose. |
| 40 | + - Run the database integration tests. |
| 41 | + - Stop the containers after tests finish. |
| 42 | + |
| 43 | + You can also run tests for a specific database: |
| 44 | + ```bash |
| 45 | + ./scripts/run_db_tests.sh --postgres |
| 46 | + # or |
| 47 | + ./scripts/run_db_tests.sh --mysql |
| 48 | + ``` |
| 49 | + |
| 50 | + To keep the databases running for debugging: |
| 51 | + ```bash |
| 52 | + ./scripts/run_db_tests.sh --debug |
| 53 | + ``` |
| 54 | + (Follow the onscreen instructions to export DSNs and run pytest manually). |
| 55 | + |
8 | 56 | In case of failures, you can clean up the cache: |
9 | 57 |
|
10 | 58 | 1. `uv clean` |
|
0 commit comments