summaryrefslogtreecommitdiff
path: root/test_tablib.py
diff options
context:
space:
mode:
authorMark Walling <mark@markwalling.org>2011-07-11 17:13:47 -0400
committerMark Walling <mark@markwalling.org>2011-07-11 17:26:21 -0400
commite74a8f41cc0bdfe1cb9aae90b9240fd15208e9cb (patch)
tree01cc0408ffea156442f723de66ead76ba9dba5e5 /test_tablib.py
parentcd5aa4fc06d9af90b076c02a9f596bb84db1d09f (diff)
downloadtablib-e74a8f41cc0bdfe1cb9aae90b9240fd15208e9cb.tar.gz
Created get_col method with tests and tutorial.rst update
Useful when you have multiple columns with the same header
Diffstat (limited to 'test_tablib.py')
-rwxr-xr-xtest_tablib.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test_tablib.py b/test_tablib.py
index 5fdf65a..48990a7 100755
--- a/test_tablib.py
+++ b/test_tablib.py
@@ -113,6 +113,22 @@ class TablibTestCase(unittest.TestCase):
[self.john[2], self.george[2], self.tom[2]])
+ def test_get_col(self):
+ """Verify getting columns by index"""
+
+ self.assertEqual(
+ self.founders.get_col(self.headers.index('first_name')),
+ [self.john[0], self.george[0], self.tom[0]])
+
+ self.assertEqual(
+ self.founders.get_col(self.headers.index('last_name')),
+ [self.john[1], self.george[1], self.tom[1]])
+
+ self.assertEqual(
+ self.founders.get_col(self.headers.index('gpa')),
+ [self.john[2], self.george[2], self.tom[2]])
+
+
def test_data_slicing(self):
"""Verify slicing by data."""