hopefully make py2.4 compatible

This commit is contained in:
chrisw 2010-09-07 19:19:32 +01:00
parent cade5fb261
commit ac848a295a
2 changed files with 24 additions and 6 deletions

View File

@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import with_statement
import sqlalchemy
import warnings
@ -551,7 +550,11 @@ class TestColumnChange(fixture.DB):
@fixture.usedb()
def test_alter_metadata_deprecated(self):
with catch_warnings(record=True) as w:
try:
# py 2.4 compatability :-/
cw = catch_warnings(record=True)
w = cw.__enter__()
warnings.simplefilter("always")
self.table.c.data.alter(Column('data', String(100)))
@ -562,7 +565,9 @@ class TestColumnChange(fixture.DB):
'Passing a Column object to alter_column is deprecated. '
'Just pass in keyword parameters instead.',
str(w[-1].message))
finally:
cw.__exit__()
@fixture.usedb()
def test_alter_metadata(self):
"""Test if alter_metadata is respected"""

View File

@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import with_statement
import os
@ -41,7 +40,11 @@ class TestUtil(fixture.Pathed):
self.assertTrue(engine.dialect.encoding)
# deprecated echo=True parameter
with catch_warnings(record=True) as w:
try:
# py 2.4 compatability :-/
cw = catch_warnings(record=True)
w = cw.__enter__()
warnings.simplefilter("always")
engine = construct_engine(url, echo='True')
self.assertTrue(engine.echo)
@ -54,6 +57,9 @@ class TestUtil(fixture.Pathed):
'engine_arg_echo=True or engine_dict={"echo": True}',
str(w[-1].message))
finally:
cw.__exit__()
# unsupported argument
self.assertRaises(ValueError, construct_engine, 1)
@ -83,7 +89,11 @@ class TestUtil(fixture.Pathed):
f.write("class FakeFloat(int): pass")
f.close()
with catch_warnings(record=True) as w:
try:
# py 2.4 compatability :-/
cw = catch_warnings(record=True)
w = cw.__enter__()
warnings.simplefilter("always")
# deprecated spelling
@ -97,6 +107,9 @@ class TestUtil(fixture.Pathed):
'model should be in form of module.model:User '
'and not module.model.User',
str(w[-1].message))
finally:
cw.__exit__()
FakeFloat = load_model('test_load_model:FakeFloat')
self.assert_(isinstance(FakeFloat(), int))