Skip to content

Refactor sys.exit handling for tests in Actor #396

@vdusek

Description

@vdusek

Currently, the _ActorType.exit() method includes the following conditional check to prevent sys.exit() from being executed during tests:

elif os.getenv('PYTEST_CURRENT_TEST', default=False):  # noqa: PLW1508
    self.log.debug(f'Not calling sys.exit({exit_code}) because Actor is running in an unit test')

This approach relies on environment variables to modify production code behavior, which is not ideal. Instead, tests should either configure the Actor to not to call sys.exit or catch it.

There is some overlap with #389.

Related discussion: https://github.com/apify/apify-sdk-python/pull/390/files#r1948543716.

Metadata

Metadata

Assignees

Labels

t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions