21
21
from testcontainers .core .exceptions import ContainerConnectException , ContainerStartException
22
22
from testcontainers .core .labels import LABEL_SESSION_ID , SESSION_ID
23
23
from testcontainers .core .network import Network
24
+ from testcontainers .core .transferable import Transferable
24
25
from testcontainers .core .utils import is_arm , setup_logger
25
26
from testcontainers .core .waiting_utils import wait_container_is_ready , wait_for_logs
26
27
@@ -35,13 +36,6 @@ class Mount(TypedDict):
35
36
mode : str
36
37
37
38
38
- @dataclasses .dataclass
39
- class Transferrable :
40
- source : Union [bytes , PathLike ]
41
- destination_in_container : str
42
- mode : int = 0o644
43
-
44
-
45
39
class DockerContainer :
46
40
"""
47
41
Basic container object to spin up Docker instances.
@@ -80,7 +74,7 @@ def __init__(
80
74
volumes : Optional [list [tuple [str , str , str ]]] = None ,
81
75
network : Optional [Network ] = None ,
82
76
network_aliases : Optional [list [str ]] = None ,
83
- transferrables : Optional [tuple [ Transferrable ]] = None ,
77
+ transferrables : Optional [list [ Transferable ]] = None ,
84
78
** kwargs : Any ,
85
79
) -> None :
86
80
self .env = env or {}
@@ -108,7 +102,7 @@ def __init__(
108
102
self .with_network_aliases (* network_aliases )
109
103
110
104
self ._kwargs = kwargs
111
- self ._transferrables = transferrables or []
105
+ self ._transferables : list [ Transferable ] = transferrables or []
112
106
113
107
def with_env (self , key : str , value : str ) -> Self :
114
108
self .env [key ] = value
@@ -210,7 +204,7 @@ def start(self) -> Self:
210
204
211
205
logger .info ("Container started: %s" , self ._container .short_id )
212
206
213
- for t in self ._transferrables :
207
+ for t in self ._transferables :
214
208
self ._transfer_into_container (t .source , t .destination_in_container , t .mode )
215
209
216
210
return self
@@ -293,10 +287,10 @@ def _configure(self) -> None:
293
287
def with_copy_into_container (
294
288
self , file_content : bytes | PathLike , destination_in_container : str , mode : int = 0o644
295
289
):
296
- self ._transferrables .append (Transferrable (file_content , destination_in_container , mode ))
290
+ self ._transferables .append (Transferable (file_content , destination_in_container , mode ))
297
291
return self
298
292
299
- def copy_into_container (self , file_content : bytes , destination_in_container : str , mode : int = 0o644 ):
293
+ def copy_into_container (self , file_content : bytes | PathLike , destination_in_container : str , mode : int = 0o644 ):
300
294
return self ._transfer_into_container (file_content , destination_in_container , mode )
301
295
302
296
def _transfer_into_container (self , source : bytes | PathLike , destination_in_container : str , mode : int ):
0 commit comments