Skip to content

Commit

Permalink
implement/test slicing
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed May 4, 2013
1 parent 0ce4ec9 commit 4c8a54d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Record/__init__.py
Expand Up @@ -93,3 +93,12 @@ def __delitem__(self, key):

def __contains__(self, key):
return key in self._schema

def __getslice__(self, i, j):
raise TypeError('Record objects do not support slicing')

def __setslice__(self, i, j, sequence):
raise TypeError('Record objects do not support slicing')

def __delslice__(self, i, j):
raise TypeError('Record objects do not support slicing')
6 changes: 6 additions & 0 deletions src/Record/tests.py
Expand Up @@ -126,3 +126,9 @@ def test_contains(self):
self.assertTrue('a' in r)
self.assertTrue('c' in r)
self.assertFalse('d' in r)

def test_slice(self):
r = R((1, 2, None))
self.assertRaises(TypeError, r.__getslice__, 0, 1)
self.assertRaises(TypeError, r.__setslice__, 0, 1, (1, 2))
self.assertRaises(TypeError, r.__delslice__, 0, 1)

0 comments on commit 4c8a54d

Please sign in to comment.