Skip to content

Commit 8b7cee0

Browse files
authored
Increase test coverage (#142)
Test stringification errors.
1 parent c00a871 commit 8b7cee0

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

tests/test_keys_iter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def test_modify_with_active_iterators(sorted_dict, iterators, advance):
3535
sorted_dict_len = len(sorted_dict)
3636
sorted_dict_keys = sorted_dict.keys()
3737
sorted_dict_keys_iters = [iter(sorted_dict_keys) for _ in range(iterators)]
38-
advances = [random.randint(0, min(advance, sorted_dict_len)) for _ in sorted_dict_keys_iters]
38+
rg = random.Random(f"{__name__}-{sorted_dict_len}-{iterators}-{advance}")
39+
advances = [rg.randint(0, min(advance, sorted_dict_len)) for _ in sorted_dict_keys_iters]
3940

4041
# Advance the iterators by the arbitrary amounts determined above. Record
4142
# the keys the iterators point to as locked keys.

tests/test_uncommon_errors.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import re
2+
3+
import pytest
4+
5+
from pysorteddict import SortedDict
6+
7+
8+
def test_key_repr_error():
9+
sorted_dict = SortedDict()
10+
sorted_dict[2**15000] = 0
11+
with pytest.raises(ValueError, match=re.escape("Exceeds the limit")):
12+
str(sorted_dict)
13+
14+
15+
def test_value_repr_error():
16+
sorted_dict = SortedDict()
17+
sorted_dict[0] = 2**15000
18+
with pytest.raises(ValueError, match=re.escape("Exceeds the limit")):
19+
str(sorted_dict)

0 commit comments

Comments
 (0)