Browse Source

Add test for Table.__getitem__ indexing

tags/nilmdb-1.4.0
Jim Paris 10 years ago
parent
commit
88eb0123f5
2 changed files with 3 additions and 1 deletions
  1. +1
    -1
      nilmdb/server/bulkdata.py
  2. +2
    -0
      tests/test_bulkdata.py

+ 1
- 1
nilmdb/server/bulkdata.py View File

@@ -480,7 +480,7 @@ class Table(object):

def __getitem__(self, row):
"""Extract timestamps from a row, with table[n] notation."""
if (row is None or row < 0 or row >= self.nrows):
if row < 0 or row >= self.nrows:
raise IndexError("Index out of range")
(subdir, filename, offset, count) = self._offset_from_row(row)
f = self.file_open(subdir, filename)


+ 2
- 0
tests/test_bulkdata.py View File

@@ -59,6 +59,8 @@ class TestBulkData(object):
node = data.getnode("/foo/bar")
with assert_raises(IndexError):
x = get_node_slice(0)
with assert_raises(IndexError):
x = node[0]
raw = []
for i in range(1000):
raw.append("%d 1 2 3 4 5 6 7 8\n" % (10000 + i))


Loading…
Cancel
Save