2525from tests .load .utils import (
2626 assert_all_data_types_row ,
2727)
28- from tests .utils import preserve_environ
29-
3028
3129SUPPORTED_LOADER_FORMATS = ["parquet" , "typed-jsonl" ]
3230
@@ -160,22 +158,7 @@ def test_capabilities() -> None:
160158 assert dict (caps ) == dict (client_caps )
161159
162160
163- @pytest .mark .parametrize (
164- "use_factory_method" ,
165- [True , False ],
166- ids = ["use_factory_method" , "use_from_reference" ],
167- )
168- def test_instantiation (use_factory_method : bool ) -> None :
169- """
170- Test custom destination instantiation.
171-
172- Args:
173- use_factory_method (bool): If True, uses `dlt.destination()` (which calls
174- `Destination.from_reference()` internally). If False, calls
175- `Destination.from_reference()` directly. Both should behave identically.
176- """
177- dest_ref_func = dlt .destination if use_factory_method else Destination .from_reference
178-
161+ def test_instantiation () -> None :
179162 # also tests DESTINATIONS registry
180163 calls : List [Tuple [TDataItems , TTableSchema ]] = []
181164
@@ -201,7 +184,7 @@ def local_sink_func(items: TDataItems, table: TTableSchema, my_val=dlt.config.va
201184 calls = []
202185 p = dlt .pipeline (
203186 "sink_test" ,
204- destination = dest_ref_func ("destination" , destination_callable = local_sink_func ),
187+ destination = Destination . from_reference ("destination" , destination_callable = local_sink_func ),
205188 dev_mode = True ,
206189 )
207190 p .run ([1 , 2 , 3 ], table_name = "items" )
@@ -217,7 +200,9 @@ def local_sink_func_no_params(items: TDataItems, table: TTableSchema) -> None:
217200
218201 p = dlt .pipeline (
219202 "sink_test" ,
220- destination = dest_ref_func ("destination" , destination_callable = local_sink_func_no_params ),
203+ destination = Destination .from_reference (
204+ "destination" , destination_callable = local_sink_func_no_params
205+ ),
221206 dev_mode = True ,
222207 )
223208 p .run ([1 , 2 , 3 ], table_name = "items" )
@@ -226,11 +211,10 @@ def local_sink_func_no_params(items: TDataItems, table: TTableSchema) -> None:
226211 global global_calls
227212 global_calls = []
228213 # this is technically possible but should not be used
229- dest_ref = dest_ref_func (
214+ dest_ref = Destination . from_reference (
230215 "destination" ,
231216 destination_callable = "tests.destinations.test_custom_destination.global_sink_func" ,
232217 )
233-
234218 assert dest_ref .destination_name == "global_sink_func"
235219 # type comes from the "destination" wrapper destination
236220 assert dest_ref .destination_type == "dlt.destinations.destination"
@@ -260,11 +244,10 @@ def local_sink_func_no_params(items: TDataItems, table: TTableSchema) -> None:
260244 assert len (global_calls ) == 2
261245
262246 # we can import type (it is not a ref)
263- dest_ref = dest_ref_func (
247+ dest_ref = Destination . from_reference (
264248 "tests.destinations.test_custom_destination.GlobalSinkFuncDestination" ,
265249 destination_name = "alt_name" ,
266250 )
267-
268251 assert dest_ref .destination_name == "alt_name"
269252 assert (
270253 dest_ref .destination_type
@@ -280,7 +263,9 @@ def local_sink_func_no_params(items: TDataItems, table: TTableSchema) -> None:
280263 assert len (global_calls ) == 3
281264
282265 # now import by ref
283- dest_ref = dest_ref_func ("tests.destinations.test_custom_destination.global_sink_func" )
266+ dest_ref = Destination .from_reference (
267+ "tests.destinations.test_custom_destination.global_sink_func"
268+ )
284269 assert dest_ref .destination_name == "global_sink_func"
285270 assert (
286271 dest_ref .destination_type
@@ -298,7 +283,7 @@ def local_sink_func_no_params(items: TDataItems, table: TTableSchema) -> None:
298283 # pass None as callable arg will fail on load
299284 p = dlt .pipeline (
300285 "sink_test" ,
301- destination = dest_ref_func ("destination" , destination_callable = None ),
286+ destination = Destination . from_reference ("destination" , destination_callable = None ),
302287 dev_mode = True ,
303288 )
304289 with pytest .raises (ConfigurationValueError ):
@@ -308,7 +293,9 @@ def local_sink_func_no_params(items: TDataItems, table: TTableSchema) -> None:
308293 with pytest .raises (UnknownCustomDestinationCallable ):
309294 p = dlt .pipeline (
310295 "sink_test" ,
311- destination = dest_ref_func ("destination" , destination_callable = "does.not.exist" ),
296+ destination = Destination .from_reference (
297+ "destination" , destination_callable = "does.not.exist"
298+ ),
312299 dev_mode = True ,
313300 )
314301
0 commit comments