1
from sqlalchemy.test.testing import eq_
1
from test.lib.testing import eq_
2
2
from sqlalchemy.orm import mapper, relationship, create_session, \
3
3
clear_mappers, sessionmaker, class_mapper
4
4
from sqlalchemy.orm.mapper import _mapper_registry
5
5
from sqlalchemy.orm.session import _sessions
6
from sqlalchemy.util import jython
8
from sqlalchemy.test import testing, engines
7
from test.lib import testing, engines
9
8
from sqlalchemy import MetaData, Integer, String, ForeignKey, \
10
9
PickleType, create_engine, Unicode
11
from sqlalchemy.test.schema import Table, Column
10
from test.lib.schema import Table, Column
12
11
import sqlalchemy as sa
13
12
from sqlalchemy.sql import column
14
13
from sqlalchemy.processors import to_decimal_processor_factory, \
15
14
to_unicode_processor_factory
16
from sqlalchemy.test.util import gc_collect
17
from decimal import Decimal as _python_Decimal
15
from test.lib.util import gc_collect
16
from sqlalchemy.util.compat import decimal
20
from test.orm import _base
23
from nose import SkipTest
24
raise SkipTest("Profiling not supported on this platform")
27
class A(_base.ComparableEntity):
19
from test.lib import fixtures
21
class A(fixtures.ComparableEntity):
29
class B(_base.ComparableEntity):
23
class B(fixtures.ComparableEntity):
32
26
def profile_memory(func):
69
63
assert len(_mapper_registry) == 0
71
class EnsureZeroed(_base.ORMTest):
65
class EnsureZeroed(fixtures.ORMTest):
74
68
_mapper_registry.clear()
76
70
class MemUsageTest(EnsureZeroed):
72
__requires__ = 'cpython',
78
74
# ensure a pure growing test trips the assertion
79
75
@testing.fails_if(lambda: True)
80
76
def test_fixture(self):
177
173
engine = engines.testing_engine(
178
174
options={'logging_name':'FOO',
179
'pool_logging_name':'BAR'}
175
'pool_logging_name':'BAR',
181
178
sess = create_session(bind=engine)
212
209
assert_no_mappers()
211
def test_ad_hoc_types(self):
212
"""test storage of bind processors, result processors
213
in dialect-wide registry."""
215
from sqlalchemy.dialects import mysql, postgresql, sqlite
216
from sqlalchemy import types
218
eng = engines.testing_engine()
222
(types.PickleType, ),
223
(types.Enum, 'a', 'b', 'c'),
225
(postgresql.ENUM, 'a', 'b', 'c'),
227
(postgresql.INTERVAL, ),
232
type_ = args[0](*args[1:])
233
bp = type_._cached_bind_processor(eng.dialect)
234
rp = type_._cached_result_processor(eng.dialect, 0)
237
assert not eng.dialect._type_memos
214
240
def test_many_updates(self):
215
241
metadata = MetaData(testing.db)
428
class A(_base.ComparableEntity):
454
class A(fixtures.ComparableEntity):
430
class B(_base.ComparableEntity):
456
class B(fixtures.ComparableEntity):
433
459
mapper(A, table1, properties={
517
543
table1 = Table("mytable", metadata,
518
544
Column('col1', Integer, primary_key=True,
519
545
test_needs_autoincrement=True),
520
Column('col2', PickleType(comparator=operator.eq))
546
Column('col2', PickleType(comparator=operator.eq, mutable=True))
523
549
class Foo(object):
580
606
def test_DecimalResultProcessor_process(self):
583
to_decimal_processor_factory(_python_Decimal, 10)(1.2)
609
to_decimal_processor_factory(decimal.Decimal, 10)(1.2)
586
612
@testing.requires.cextensions