@@ -455,6 +455,31 @@ def test_stream_with_out_of_bounds_weight_is_error(self, weight):
455455 err .value .args [0 ] ==
456456 'Stream weight must be between 1 and 256 (inclusive)' )
457457
458+ @pytest .mark .parametrize ('exclusive' , (True , False ))
459+ @pytest .mark .parametrize ('stream_id' , (1 , 5 , 20 , 32 , 256 ))
460+ def test_stream_depending_on_self_is_error (self , stream_id , exclusive ):
461+ """
462+ Inserting a stream that is dependent on itself is rejected.
463+ """
464+ p = priority .PriorityTree ()
465+ with pytest .raises (priority .PriorityLoop ):
466+ p .insert_stream (
467+ stream_id = stream_id , depends_on = stream_id , exclusive = exclusive
468+ )
469+
470+ @pytest .mark .parametrize ('exclusive' , (True , False ))
471+ @pytest .mark .parametrize ('stream_id' , (1 , 5 , 20 , 32 , 256 ))
472+ def test_reprioritize_depend_on_self_is_error (self , stream_id , exclusive ):
473+ """
474+ Reprioritizing a stream to make it dependent on itself is an error.
475+ """
476+ p = priority .PriorityTree ()
477+ p .insert_stream (stream_id = stream_id )
478+ with pytest .raises (priority .PriorityLoop ):
479+ p .reprioritize (
480+ stream_id = stream_id , depends_on = stream_id , exclusive = exclusive
481+ )
482+
458483
459484class TestPriorityTreeOutput (object ):
460485 """
0 commit comments