Skip to content

Auto-detect when running in the screenshot generator #795

@kdmukai

Description

@kdmukai

In at least one instance (and in PR #758) we need to pass an is_screenshot_generator cue to a View in order to alter rendering behavior (usually thread management) to be compatible with the screenshot generator.

Since the screenshot generator is just monkey patching over the normal Renderer, we can probably just provide a test in the Controller or maybe just directly in the Renderer that can tell us which Renderer is instantiated.

Actually, most likely it's easiest to just add a property to the Renderer:

class Renderer:
    @property
    def is_screenshot_generator(self) -> bool:
        return False

...

# in the tests world:
class ScreenshotRenderer(Renderer):
    @property
    def is_screenshot_generator(self) -> bool:
        return True

So if we had this in place, in the few instances when a piece of code needs to alter its behavior for the screenshot renderer, we wouldn't have to explicitly pass in this is_screenshot_renderer arg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions