diff options
| author | Diana Clarke <diana.joan.clarke@gmail.com> | 2012-11-17 15:28:50 -0500 |
|---|---|---|
| committer | Diana Clarke <diana.joan.clarke@gmail.com> | 2012-11-17 15:28:50 -0500 |
| commit | 40071dbda4c2467f10a1ef217ce1d6e64058fba3 (patch) | |
| tree | 02126593dc602dff8617b8b78846d4d6ce1a6d32 /test/base | |
| parent | dbdd0fdd48bc0baf13a614fd193ad4fd6f697840 (diff) | |
| download | sqlalchemy-40071dbda4c2467f10a1ef217ce1d6e64058fba3.tar.gz | |
initializing _labels to an empty list so that the other methods don't throw exceptions in the None labels case, but rather return (), [], or {}. this is not backwards compatible, but doubt anyone is relying on those exceptions #2601
Diffstat (limited to 'test/base')
| -rw-r--r-- | test/base/test_utils.py | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index fe46377a2..af881af17 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -13,35 +13,26 @@ class KeyedTupleTest(): keyed_tuple = util.KeyedTuple([]) eq_(type(keyed_tuple), util.KeyedTuple) eq_(str(keyed_tuple), '()') - eq_(keyed_tuple.__dict__, {}) + eq_(len(keyed_tuple), 0) - # TODO: consider returning an empty [] rather than raising - assert_raises(AttributeError, keyed_tuple.keys) - - # TODO: consider returning an empty {} rather than raising - assert_raises(AttributeError, keyed_tuple._asdict) - - # TODO: consider returning an empty () rather than raising - def should_raise(): - keyed_tuple._fields - assert_raises(AttributeError, should_raise) + eq_(keyed_tuple.__dict__, {'_labels': []}) + eq_(keyed_tuple.keys(), []) + eq_(keyed_tuple._fields, ()) + eq_(keyed_tuple._asdict(), {}) def test_values_but_no_labels(self): keyed_tuple = util.KeyedTuple([1, 2]) eq_(type(keyed_tuple), util.KeyedTuple) eq_(str(keyed_tuple), '(1, 2)') - eq_(keyed_tuple.__dict__, {}) - - # TODO: consider returning an empty [] rather than raising - assert_raises(AttributeError, keyed_tuple.keys) + eq_(len(keyed_tuple), 2) - # TODO: consider returning an empty {} rather than raising - assert_raises(AttributeError, keyed_tuple._asdict) + eq_(keyed_tuple.__dict__, {'_labels': []}) + eq_(keyed_tuple.keys(), []) + eq_(keyed_tuple._fields, ()) + eq_(keyed_tuple._asdict(), {}) - # TODO: consider returning an empty () rather than raising - def should_raise(): - keyed_tuple._fields - assert_raises(AttributeError, should_raise) + eq_(keyed_tuple[0], 1) + eq_(keyed_tuple[1], 2) def test_basic_creation(self): keyed_tuple = util.KeyedTuple([1, 2], ['a', 'b']) |
