diff --git a/behave_utils/docker.py b/behave_utils/docker.py index 7f407683a636cca0652d5c0c53ba88e02f50b5cc..0d682ae229c546b86e394c22b83bf47595a86ab5 100644 --- a/behave_utils/docker.py +++ b/behave_utils/docker.py @@ -222,7 +222,7 @@ class Container(Item): self.stop(rm=True) @contextmanager - def started(self) -> Iterator[Container]: + def started(self: T) -> Iterator[T]: """ Return a context manager that ensures the container is started when the context is entered """ diff --git a/behave_utils/mysql.py b/behave_utils/mysql.py index fdf8ca5883bc26ed5b9b65ba500174a7e6b38f8a..13c98b7cfab01c30ab3e166dd45bbcacede4b009 100644 --- a/behave_utils/mysql.py +++ b/behave_utils/mysql.py @@ -16,6 +16,7 @@ from time import sleep from typing import TYPE_CHECKING from typing import Iterator from typing import Sequence +from typing import TypeVar from behave import fixture @@ -39,6 +40,8 @@ class Mysql(Container): Container subclass for a database container """ + T = TypeVar('T', bound='Mysql') + def __init__( self, version: str = "latest", @@ -95,7 +98,7 @@ class Mysql(Container): return Cli(self, "mysqldump") @contextmanager - def started(self) -> Iterator[Container]: + def started(self: T) -> Iterator[T]: """ Return a context manager that only enters once the database is initialised """