Permalink
Browse files

Raise TypeError on bad ColFam init kwargs

Fixes #165
  • Loading branch information...
1 parent 64f2fb6 commit 7df4c01a03174617dc4a13ee9a8d006febfa0730 @thobbs thobbs committed Jul 23, 2012
Showing with 13 additions and 5 deletions.
  1. +9 −5 pycassa/columnfamily.py
  2. +4 −0 tests/test_columnfamily.py
View
@@ -282,14 +282,18 @@ def __init__(self, pool, column_family, **kwargs):
self.timestamp = gm_timestamp
self.load_schema()
- recognized_kwargs = ["buffer_size", "read_consistency_level",
+ recognized_kwargs = ("buffer_size", "read_consistency_level",
"write_consistency_level", "timestamp",
"dict_class", "buffer_size", "autopack_names",
"autopack_values", "autopack_keys",
- "retry_counter_mutations"]
- for kw in recognized_kwargs:
- if kw in kwargs:
- setattr(self, kw, kwargs[kw])
+ "retry_counter_mutations")
+ for k, v in kwargs.iteritems():
+ if k in recognized_kwargs:
+ setattr(self, k, v)
+ else:
+ raise TypeError(
+ "ColumnFamily.__init__() got an unexpected keyword "
+ "argument '%s'" % (k,))
def load_schema(self):
"""
@@ -38,6 +38,10 @@ def tearDown(self):
for key, columns in indexed_cf.get_range():
cf.remove(key)
+ def test_bad_kwarg(self):
+ assert_raises(TypeError,
+ ColumnFamily.__init__, pool, 'test', bar='foo')
+
def test_empty(self):
key = 'TestColumnFamily.test_empty'
assert_raises(NotFoundException, cf.get, key)

0 comments on commit 7df4c01

Please sign in to comment.