From 2e016dd625a01a12849b94e11685bdac9d3fcdfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Sun, 19 Jan 2020 21:55:26 +0100 Subject: [PATCH] extra unit tests and doc fixes --- CHANGELOG.md | 1 + README.md | 2 +- satella/__init__.py | 2 +- satella/coding/structures/structures.py | 15 ++++++--------- tests/test_coding/test_structures.py | 1 + 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d66b964b..e71635bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # v2.2.13 * useless `print()`s removed in metrics +* additional unit tests and doc fixes # v2.2.12 diff --git a/README.md b/README.md index 839bdfc7..b8f864cb 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ _satella.posix_ in unavailable on non-POSIX systems, but the rest should work OK Full [documentation](http://satella.readthedocs.io/en/latest/?badge=latest) is available for the brave souls that do decide to use this library. -Satella is a zero-requirements Python 3.5+ library for writing +Satella is an almost-zero-requirements Python 3.5+ library for writing server applications, especially those dealing with mundane but useful things. It also runs on PyPy. diff --git a/satella/__init__.py b/satella/__init__.py index 3681df43..4c6704f3 100644 --- a/satella/__init__.py +++ b/satella/__init__.py @@ -1,2 +1,2 @@ # coding=UTF-8 -__version__ = '2.2.13a1' +__version__ = '2.2.13a2' diff --git a/satella/coding/structures/structures.py b/satella/coding/structures/structures.py index 9d08f5b5..793c1193 100644 --- a/satella/coding/structures/structures.py +++ b/satella/coding/structures/structures.py @@ -79,7 +79,7 @@ class Heap(collections.UserList, tp.Generic[HeapVar]): super().__init__(from_list) heapq.heapify(self.data) - def push_many(self, items: tp.Iterator[HeapVar]) -> None: + def push_many(self, items: tp.Iterable[HeapVar]) -> None: for item in items: self.push(item) @@ -88,11 +88,11 @@ class Heap(collections.UserList, tp.Generic[HeapVar]): """ Use it like: - heap.push(3) + >>> heap.push(3) or: - heap.push(4, myobject) + >>> heap.push(4, myobject) """ heapq.heappush(self.data, item) @@ -137,7 +137,7 @@ class Heap(collections.UserList, tp.Generic[HeapVar]): """ return len(self.data) > 0 - def iter_ascending(self) -> tp.Iterator[HeapVar]: + def iter_ascending(self) -> tp.Iterable[HeapVar]: """ Return an iterator returning all elements in this heap sorted ascending. State of the heap is not changed @@ -146,7 +146,7 @@ class Heap(collections.UserList, tp.Generic[HeapVar]): while heap: yield heapq.heappop(heap) - def iter_descending(self) -> tp.Iterator[HeapVar]: + def iter_descending(self) -> tp.Iterable[HeapVar]: """ Return an iterator returning all elements in this heap sorted descending. State of the heap is not changed. @@ -193,15 +193,12 @@ class TimeBasedHeap(Heap): #notthreadsafe """ - def __repr__(self): - return '<satella.coding.TimeBasedHeap>' - def __repr__(self): return '<satella.coding.TimeBasedHeap with %s elements>' % (len(self.data),) def items(self) -> tp.Iterable[HeapVar]: """ - Return an iterator, but WITHOUT timestamps (only items), in + Return an iterable, but WITHOUT timestamps (only items), in unspecified order """ return (ob for ts, ob in self.data) diff --git a/tests/test_coding/test_structures.py b/tests/test_coding/test_structures.py index 24e45a70..cce7377a 100644 --- a/tests/test_coding/test_structures.py +++ b/tests/test_coding/test_structures.py @@ -30,6 +30,7 @@ class TestTimeBasedHeap(unittest.TestCase): } self.assertEqual(a[e1], '1') + self.assertEqual(hash(e1), hash(2)) def test_tbh(self): tbh = TimeBasedHeap() -- GitLab