@@ -913,7 +913,6 @@ def error_status_test(context):
913913 with self .assertRaises (AssertionError ):
914914 with context as root :
915915 raise AssertionError ("unknown" )
916-
917916 self .assertIs (root .status .status_code , StatusCode .ERROR )
918917 self .assertEqual (
919918 root .status .description , "AssertionError: unknown"
@@ -928,18 +927,53 @@ def error_status_test(context):
928927 .start_as_current_span ("root" )
929928 )
930929
931- def test_last_status_wins (self ):
930+ def test_status_cannot_override_ok (self ):
932931 def error_status_test (context ):
933932 with self .assertRaises (AssertionError ):
934933 with context as root :
935934 root .set_status (trace_api .status .Status (StatusCode .OK ))
936935 raise AssertionError ("unknown" )
936+ self .assertIs (root .status .status_code , StatusCode .OK )
937+ self .assertIsNone (root .status .description )
938+
939+ error_status_test (
940+ trace .TracerProvider ().get_tracer (__name__ ).start_span ("root" )
941+ )
942+ error_status_test (
943+ trace .TracerProvider ()
944+ .get_tracer (__name__ )
945+ .start_as_current_span ("root" )
946+ )
937947
948+ def test_status_cannot_set_unset (self ):
949+ def unset_status_test (context ):
950+ with self .assertRaises (AssertionError ):
951+ with context as root :
952+ raise AssertionError ("unknown" )
953+ root .set_status (trace_api .status .Status (StatusCode .UNSET ))
938954 self .assertIs (root .status .status_code , StatusCode .ERROR )
939955 self .assertEqual (
940956 root .status .description , "AssertionError: unknown"
941957 )
942958
959+ unset_status_test (
960+ trace .TracerProvider ().get_tracer (__name__ ).start_span ("root" )
961+ )
962+ unset_status_test (
963+ trace .TracerProvider ()
964+ .get_tracer (__name__ )
965+ .start_as_current_span ("root" )
966+ )
967+
968+ def test_last_status_wins (self ):
969+ def error_status_test (context ):
970+ with self .assertRaises (AssertionError ):
971+ with context as root :
972+ raise AssertionError ("unknown" )
973+ root .set_status (trace_api .status .Status (StatusCode .OK ))
974+ self .assertIs (root .status .status_code , StatusCode .OK )
975+ self .assertIsNone (root .status .description )
976+
943977 error_status_test (
944978 trace .TracerProvider ().get_tracer (__name__ ).start_span ("root" )
945979 )
0 commit comments