@@ -477,6 +477,56 @@ defmodule PythonxTest do
477477 end
478478 end
479479
480+ describe "uv_init/2 native_tls option" do
481+ test "accepts native_tls option" do
482+ # Test that native_tls is recognized as a valid option
483+ opts = Keyword . validate! ( [ native_tls: true , force: false ] ,
484+ force: false ,
485+ uv_version: Pythonx.Uv . default_uv_version ( ) ,
486+ native_tls: false )
487+
488+ assert opts [ :native_tls ] == true
489+ assert opts [ :force ] == false
490+ end
491+
492+ test "defaults native_tls to false" do
493+ opts = Keyword . validate! ( [ ] ,
494+ force: false ,
495+ uv_version: Pythonx.Uv . default_uv_version ( ) ,
496+ native_tls: false )
497+
498+ assert opts [ :native_tls ] == false
499+ end
500+
501+ test "native_tls true adds --native-tls flag to uv command" do
502+ # Simulate how Pythonx.Uv.fetch constructs the uv command arguments
503+ base_args = [ "sync" , "--managed-python" , "--no-config" ]
504+ native_tls = true
505+
506+ uv_args = if native_tls , do: base_args ++ [ "--native-tls" ] , else: base_args
507+
508+ assert uv_args == [ "sync" , "--managed-python" , "--no-config" , "--native-tls" ]
509+ end
510+
511+ test "native_tls false does not add --native-tls flag" do
512+ base_args = [ "sync" , "--managed-python" , "--no-config" ]
513+ native_tls = false
514+
515+ uv_args = if native_tls , do: base_args ++ [ "--native-tls" ] , else: base_args
516+
517+ assert uv_args == [ "sync" , "--managed-python" , "--no-config" ]
518+ end
519+
520+ test "raises error for unknown options" do
521+ assert_raise ArgumentError , ~r/ unknown keys/ , fn ->
522+ Keyword . validate! ( [ unknown_option: true ] ,
523+ force: false ,
524+ uv_version: Pythonx.Uv . default_uv_version ( ) ,
525+ native_tls: false )
526+ end
527+ end
528+ end
529+
480530 defp repr ( object ) do
481531 assert % Pythonx.Object { } = object
482532
0 commit comments