Skip to content

Commit 8646c06

Browse files
committed
Address Honza's feedback
1 parent 57086f5 commit 8646c06

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

tests/integration/_utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
from crawlee._utils.crypto import crypto_random_object_id
44

55

6-
def read_file(file_path: str) -> str:
7-
"""Read the content of a file and return it as a string."""
8-
with open(file_path, encoding='utf-8') as file:
9-
return file.read()
10-
11-
126
def generate_unique_resource_name(label: str) -> str:
137
"""Generates a unique resource name, which will contain the given label."""
148
label = label.replace('_', '-')

tests/integration/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,14 @@ def __call__(
362362

363363

364364
@pytest.fixture
365-
async def run_actor(apify_client_async: ApifyClientAsync, run_input: Any = None) -> RunActorFunction:
365+
async def run_actor(apify_client_async: ApifyClientAsync) -> RunActorFunction:
366366
"""Fixture for calling an Actor run and waiting for its completion.
367367
368368
This fixture returns a function that initiates an Actor run with optional run input, waits for its completion,
369369
and retrieves the final result. It uses the `wait_for_finish` method with a timeout of 10 minutes.
370370
"""
371371

372-
async def _run_actor(actor: ActorClientAsync, *, run_input: Any = run_input) -> ActorRun:
372+
async def _run_actor(actor: ActorClientAsync, *, run_input: Any = None) -> ActorRun:
373373
call_result = await actor.call(run_input=run_input)
374374

375375
assert isinstance(call_result, dict), 'The result of ActorClientAsync.call() is not a dictionary.'

tests/integration/test_actor_scrapy.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
from __future__ import annotations
22

3+
from pathlib import Path
34
from typing import TYPE_CHECKING
45

56
if TYPE_CHECKING:
67
from .conftest import MakeActorFunction, RunActorFunction
78

8-
from ._utils import read_file
9-
109

1110
async def test_actor_scrapy_title_spider(
1211
make_actor: MakeActorFunction,
1312
run_actor: RunActorFunction,
1413
) -> None:
14+
base_path = Path('docs/02_guides/code/scrapy_project')
15+
1516
actor_source_files = {
16-
'src/__init__.py': read_file('docs/02_guides/code/scrapy_project/src/__init__.py'),
17-
'src/__main__.py': read_file('docs/02_guides/code/scrapy_project/src/__main__.py'),
18-
'src/items.py': read_file('docs/02_guides/code/scrapy_project/src/items.py'),
19-
'src/main.py': read_file('docs/02_guides/code/scrapy_project/src/main.py'),
20-
'src/settings.py': read_file('docs/02_guides/code/scrapy_project/src/settings.py'),
21-
'src/spiders/__init__.py': read_file('docs/02_guides/code/scrapy_project/src/spiders/__init__.py'),
22-
'src/spiders/title.py': read_file('docs/02_guides/code/scrapy_project/src/spiders/title.py'),
17+
'src/__init__.py': (base_path / 'src/__init__.py').read_text(),
18+
'src/__main__.py': (base_path / 'src/__main__.py').read_text(),
19+
'src/items.py': (base_path / 'src/items.py').read_text(),
20+
'src/main.py': (base_path / 'src/main.py').read_text(),
21+
'src/settings.py': (base_path / 'src/settings.py').read_text(),
22+
'src/spiders/__init__.py': (base_path / 'src/spiders/__init__.py').read_text(),
23+
'src/spiders/title.py': (base_path / 'src/spiders/title.py').read_text(),
2324
}
2425

2526
actor = await make_actor(

0 commit comments

Comments
 (0)