Commit 2c8cfdb
authored
test: Fix integration test isolation (#739)
- Fix integration test isolation to prevent random directories in
project root.
### Problem
Running integration tests created random-named directories (e.g.,
`41SJFVD7V6`, `KEIN9WBF32`) in the project root instead of using
temporary directories.
### Root cause
The main `tests/integration/conftest.py` was missing the
`prepare_test_env` fixture that sets `APIFY_LOCAL_STORAGE_DIR` to a
pytest-managed temporary directory. Without this, Crawlee's default
behavior creates randomly-named directories in the current working
directory.
### Changes
1. **Added `prepare_test_env` fixture** to
`tests/integration/conftest.py`
- Sets `APIFY_LOCAL_STORAGE_DIR` to `tmp_path`
- Resets Actor and service locator global state between tests
- Runs automatically via `_isolate_test_environment` (`autouse=True`)
2. **Removed duplicate** `tests/integration/apify_api/conftest.py`
- Contained identical fixtures now provided by parent conftest
- Tests inherit fixtures through pytest's conftest hierarchy
### Testing
After this fix, all storage directories are created under pytest's
temporary directory and automatically cleaned up after test runs.
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent 721f441 commit 2c8cfdb
2 files changed
Lines changed: 63 additions & 70 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
8 | 18 | | |
9 | 19 | | |
10 | 20 | | |
| |||
26 | 36 | | |
27 | 37 | | |
28 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
0 commit comments