Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtree.index: fix test bugs #345

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_intersection(self) -> None:
self.assertTrue(0 in self.idx.intersection((0, 0, 60, 60)))
hits = list(self.idx.intersection((0, 0, 60, 60)))

self.assertTrue(len(hits), 10)
self.assertEqual(len(hits), 10)
self.assertEqual(hits, [0, 4, 16, 27, 35, 40, 47, 50, 76, 80])

def test_objects(self) -> None:
Expand Down Expand Up @@ -436,14 +436,14 @@ def test_custom_filenames(self) -> None:
idx.add(i, coords)

hits = list(idx.intersection((0, 0, 60, 60)))
self.assertTrue(len(hits), 10)
self.assertEqual(len(hits), 10)
self.assertEqual(hits, [0, 4, 16, 27, 35, 40, 47, 50, 76, 80])
del idx

# Check we can reopen the index and get the same results
idx2 = index.Index(tname, properties=p)
hits = list(idx2.intersection((0, 0, 60, 60)))
self.assertTrue(len(hits), 10)
self.assertEqual(len(hits), 10)
self.assertEqual(hits, [0, 4, 16, 27, 35, 40, 47, 50, 76, 80])

@pytest.mark.skipif(not sys.maxsize > 2**32, reason="Fails on 32bit systems")
Expand All @@ -465,7 +465,7 @@ def data_gen(
tname, data_gen(interleaved=False), properties=p, interleaved=False
)
hits1 = sorted(list(idx.intersection((0, 60, 0, 60))))
self.assertTrue(len(hits1), 10)
self.assertEqual(len(hits1), 10)
self.assertEqual(hits1, [0, 4, 16, 27, 35, 40, 47, 50, 76, 80])

leaves = idx.leaves()
Expand Down Expand Up @@ -591,7 +591,7 @@ def data_gen(
)

hits2 = sorted(list(idx.intersection((0, 60, 0, 60), objects=True)))
self.assertTrue(len(hits2), 10)
self.assertEqual(len(hits2), 10)
self.assertEqual(hits2[0].object, 42)

def test_overwrite(self) -> None:
Expand Down Expand Up @@ -846,15 +846,11 @@ def test_custom_storage_reopening(self) -> None:
"""Reopening custom index storage works as expected"""

storage = DictStorage()
settings = index.Property()
settings.writethrough = True
settings.buffering_capacity = 1

r1 = index.Index(storage, properties=settings, overwrite=True)
r1 = index.Index(storage, overwrite=True)
r1.add(555, (2, 2))
del r1
self.assertTrue(storage.hasData)

r2 = index.Index(storage, properly=settings, overwrite=False)
r2 = index.Index(storage, overwrite=False)
count = r2.count((0, 0, 10, 10))
self.assertEqual(count, 1)
Loading