|
15 | 15 | from apify_client import ApifyClient, ApifyClientAsync
|
16 | 16 | from apify_shared.consts import ActorJobStatus, ActorSourceType, ApifyEnvVars
|
17 | 17 | from crawlee import service_locator
|
18 |
| -from crawlee.storages import _creation_management |
| 18 | +from crawlee.storages import Dataset, KeyValueStore, RequestQueue |
19 | 19 |
|
20 | 20 | import apify._actor
|
21 | 21 | from ._utils import generate_unique_resource_name
|
@@ -65,12 +65,15 @@ def _prepare_test_env() -> None:
|
65 | 65 | service_locator._storage_client = None
|
66 | 66 |
|
67 | 67 | # Clear creation-related caches to ensure no state is carried over between tests.
|
68 |
| - monkeypatch.setattr(_creation_management, '_cache_dataset_by_id', {}) |
69 |
| - monkeypatch.setattr(_creation_management, '_cache_dataset_by_name', {}) |
70 |
| - monkeypatch.setattr(_creation_management, '_cache_kvs_by_id', {}) |
71 |
| - monkeypatch.setattr(_creation_management, '_cache_kvs_by_name', {}) |
72 |
| - monkeypatch.setattr(_creation_management, '_cache_rq_by_id', {}) |
73 |
| - monkeypatch.setattr(_creation_management, '_cache_rq_by_name', {}) |
| 68 | + Dataset._cache_by_id.clear() |
| 69 | + Dataset._cache_by_name.clear() |
| 70 | + Dataset._default_instance = None |
| 71 | + KeyValueStore._cache_by_id.clear() |
| 72 | + KeyValueStore._cache_by_name.clear() |
| 73 | + KeyValueStore._default_instance = None |
| 74 | + RequestQueue._cache_by_id.clear() |
| 75 | + RequestQueue._cache_by_name.clear() |
| 76 | + RequestQueue._default_instance = None |
74 | 77 |
|
75 | 78 | # Verify that the test environment was set up correctly.
|
76 | 79 | assert os.environ.get(ApifyEnvVars.LOCAL_STORAGE_DIR) == str(tmp_path)
|
|
0 commit comments