mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Merge pull request #189 from tsroten/issue_184
Fixes Row slicing. Fixes #184.
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ class Row(object):
|
||||
return repr(self._row)
|
||||
|
||||
def __getslice__(self, i, j):
|
||||
return self._row[i,j]
|
||||
return self._row[i:j]
|
||||
|
||||
def __getitem__(self, i):
|
||||
return self._row[i]
|
||||
|
||||
@@ -8,6 +8,7 @@ import sys
|
||||
import os
|
||||
import tablib
|
||||
from tablib.compat import markup, unicode, is_py3
|
||||
from tablib.core import Row
|
||||
|
||||
|
||||
|
||||
@@ -206,6 +207,18 @@ class TablibTestCase(unittest.TestCase):
|
||||
self.assertEqual(self.founders[2:], [self.tom])
|
||||
|
||||
|
||||
def test_row_slicing(self):
|
||||
"""Verify Row's __getslice__ method. Issue #184."""
|
||||
|
||||
john = Row(self.john)
|
||||
|
||||
self.assertEqual(john[:], list(self.john[:]))
|
||||
self.assertEqual(john[0:], list(self.john[0:]))
|
||||
self.assertEqual(john[:2], list(self.john[:2]))
|
||||
self.assertEqual(john[0:2], list(self.john[0:2]))
|
||||
self.assertEqual(john[0:-1], list(self.john[0:-1]))
|
||||
|
||||
|
||||
def test_delete(self):
|
||||
"""Verify deleting from dataset works."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user