diff options
| author | Luke Lee <durdenmisc@gmail.com> | 2010-09-13 21:03:29 -0500 |
|---|---|---|
| committer | Luke Lee <durdenmisc@gmail.com> | 2010-09-13 21:03:29 -0500 |
| commit | f01cf184d4d1a94ac16ac33e84bb6ea71d9ff485 (patch) | |
| tree | 883e97ee1316718567f0ba7876127afb25d04aef /test_tablib.py | |
| parent | 1482ca4a198579afaa3f2a191ad2f468b28d2b37 (diff) | |
| download | tablib-f01cf184d4d1a94ac16ac33e84bb6ea71d9ff485.tar.gz | |
Added simple test for slicing by headers
Diffstat (limited to 'test_tablib.py')
| -rw-r--r-- | test_tablib.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test_tablib.py b/test_tablib.py index 13aa66b..f63ba9d 100644 --- a/test_tablib.py +++ b/test_tablib.py @@ -26,7 +26,9 @@ class TablibTestCase(unittest.TestCase): new_row = (1, 2, 3) data.append(new_row) + # Verify width/data self.assertTrue(data.width == len(new_row)) + self.assertTrue(data[0] == new_row) def test_empty_append_with_headers(self): """Verify append() correctly detects mismatch of number of @@ -39,6 +41,23 @@ class TablibTestCase(unittest.TestCase): self.assertRaises(tablib.InvalidDimensions, data.append, new_row) + def test_header_slicing(self): + """Verify slicing by headers""" + + headers = ('first_name', 'last_name', 'gpa') + + data = [ + ('John', 'Adams', 90), + ('George', 'Washington', 67) + ] + + data = tablib.Dataset(*data, headers=headers) + + # Slice by headers + self.assertEqual(data['first_name'], ['John', 'George']) + self.assertEqual(data['last_name'], ['Adams', 'Washington']) + self.assertEqual(data['gpa'], [90, 67]) + # def test_adding_header with (self): |
