Hi,
I was attempting to subclass testcontainers.selenium.BrowserWebDriverContainer and ran into an issue.
def __init__(self, capabilities, image=None):
self.capabilities = capabilities
if not image:
self.image = get_image_name(capabilities)
self.port_to_expose = 4444
self.vnc_port_to_expose = 5900
super(BrowserWebDriverContainer, self).__init__(image=self.image)
self.with_exposed_ports(self.port_to_expose, self.vnc_port_to_expose)
This __init__ does not account for when a user specifies the input image . As shown above, there needs to be an else statement for image so that we don't hit a NameError because self.image does not get declared if the user provides a custom URL for the image.
I am using an image from my company's Docker registry as I cannot download outside images.
I'd like to submit a PR that can solve this.
The change I'd make is
def __init__(self, capabilities, image=None):
self.capabilities = capabilities
if image is None:
self.image = get_image_name(capabilities)
else:
self.image = image
self.port_to_expose = 4444
self.vnc_port_to_expose = 5900
super(BrowserWebDriverContainer, self).__init__(image=self.image)
self.with_exposed_ports(self.port_to_expose, self.vnc_port_to_expose)
For reference see testcontainers.redis.RedisContainer; in particular: super(RedisContainer, self).__init__(image) where a user-supplied image will be passed to the underlying class DockerContainer.
Hi,
I was attempting to subclass
testcontainers.selenium.BrowserWebDriverContainerand ran into an issue.This
__init__does not account for when a user specifies the inputimage. As shown above, there needs to be an else statement forimageso that we don't hit aNameErrorbecauseself.imagedoes not get declared if the user provides a custom URL for the image.I am using an image from my company's Docker registry as I cannot download outside images.
I'd like to submit a PR that can solve this.
The change I'd make is
For reference see
testcontainers.redis.RedisContainer; in particular:super(RedisContainer, self).__init__(image)where a user-suppliedimagewill be passed to the underlying classDockerContainer.