Skip to content

prefect.testing.docker

capture_builders()

Captures any instances of ImageBuilder created while this context is active

Source code in src/prefect/testing/docker.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
@contextmanager
def capture_builders() -> Generator[List[ImageBuilder], None, None]:
    """Captures any instances of ImageBuilder created while this context is active"""
    builders = []

    original_init = ImageBuilder.__init__

    def capture(self, *args, **kwargs):
        builders.append(self)
        original_init(self, *args, **kwargs)

    with mock.patch.object(ImageBuilder, "__init__", capture):
        yield builders