Skip to content

Commit 4c89292

Browse files
committed
Test that streams must not depend on themselves.
1 parent ad45291 commit 4c89292

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/test_priority.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

459484
class TestPriorityTreeOutput(object):
460485
"""

0 commit comments

Comments
 (0)