diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-10-23 13:05:56 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-10-23 13:05:56 -0400 |
| commit | a708d0fbce3b7d8a9fb575bab5229a9b6b5f8f3a (patch) | |
| tree | 8a7f56ba30e806d36f4f946e35a00b33343a0dd6 /test/sql | |
| parent | 408c1899956cb860badc6be106c7db81ad645247 (diff) | |
| download | sqlalchemy-a708d0fbce3b7d8a9fb575bab5229a9b6b5f8f3a.tar.gz | |
- Added accessor to types called "python_type",
returns the rudimentary Python type object
for a particular TypeEngine instance, if known,
else raises NotImplementedError. [ticket:77]
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_types.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 77d6bb506..50cb0ba06 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -130,6 +130,32 @@ class AdaptTest(fixtures.TestBase): getattr(t2, k) == t1.__dict__[k] or \ t1.__dict__[k] is None + def test_python_type(self): + eq_(types.Integer().python_type, int) + eq_(types.Numeric().python_type, decimal.Decimal) + eq_(types.Numeric(asdecimal=False).python_type, float) + # Py3K + #eq_(types.LargeBinary().python_type, bytes) + # Py2K + eq_(types.LargeBinary().python_type, str) + # end Py2K + eq_(types.Float().python_type, float) + eq_(types.Interval().python_type, datetime.timedelta) + eq_(types.Date().python_type, datetime.date) + eq_(types.DateTime().python_type, datetime.datetime) + # Py3K + #eq_(types.String().python_type, unicode) + # Py2K + eq_(types.String().python_type, str) + # end Py2K + eq_(types.Unicode().python_type, unicode) + eq_(types.String(convert_unicode=True).python_type, unicode) + + assert_raises( + NotImplementedError, + lambda: types.TypeEngine().python_type + ) + @testing.uses_deprecated() def test_repr(self): for typ in self._all_types(): |
