logging.getLogger('sqlalchemy.engine').removeHandler(self.buf)
logging.getLogger('sqlalchemy.engine').setLevel(self.level)
- def testing_engine(self):
+ def _testing_engine(self):
e = engines.testing_engine()
# do an initial execute to clear out 'first connect'
def test_echo_flag_independence(self):
"""test the echo flag's independence to a specific engine."""
- e1 = self.testing_engine()
- e2 = self.testing_engine()
+ e1 = self._testing_engine()
+ e2 = self._testing_engine()
e1.echo = True
e1.execute(select([1])).close()
p.dispose()
p.recreate()
- def testthreadlocal_del(self):
+ def test_threadlocal_del(self):
self._do_testthreadlocal(useclose=False)
- def testthreadlocal_close(self):
+ def test_threadlocal_close(self):
self._do_testthreadlocal(useclose=True)
def _do_testthreadlocal(self, useclose=False):
c.close()
assert counts == [1, 2, 2]
+
class QueuePoolTest(PoolTestBase):
- def testqueuepool_del(self):
+ def test_queuepool_del(self):
self._do_testqueuepool(useclose=False)
- def testqueuepool_close(self):
+ def test_queuepool_close(self):
self._do_testqueuepool(useclose=True)
def _do_testqueuepool(self, useclose=False):
eq_(oi, ['orders', 'items'])
- def testcheckfirst(self):
+ def test_checkfirst(self):
try:
assert not users.exists(testing.db)
users.create(bind=testing.db)
assert a1.a2b_name is None
assert a1.b_single is None
- def custom_getset_test(self):
+ def test_custom_getset(self):
metadata = MetaData()
p = Table('p', metadata,
Column('id', Integer, primary_key=True),
Column('id', Integer, ForeignKey('b.id'), primary_key=True),
Column('cdata', String(30)))
- def make_test(fetchtype):
+ def _make_test(fetchtype):
def test_roundtrip(self):
class A(fixtures.ComparableEntity):pass
class B(A):pass
test_roundtrip, 'test_%s' % fetchtype)
return test_roundtrip
- test_union = make_test('union')
- test_none = make_test('none')
+ test_union = _make_test('union')
+ test_none = _make_test('none')
Column('data', String(30))
)
- def testrelationshiponsubclass_j1_nodata(self):
- self.do_test("join1", False)
- def testrelationshiponsubclass_j2_nodata(self):
- self.do_test("join2", False)
- def testrelationshiponsubclass_j1_data(self):
- self.do_test("join1", True)
- def testrelationshiponsubclass_j2_data(self):
- self.do_test("join2", True)
- def testrelationshiponsubclass_j3_nodata(self):
- self.do_test("join3", False)
- def testrelationshiponsubclass_j3_data(self):
- self.do_test("join3", True)
-
- def do_test(self, jointype="join1", usedata=False):
+ def test_relationshiponsubclass_j1_nodata(self):
+ self._do_test("join1", False)
+ def test_relationshiponsubclass_j2_nodata(self):
+ self._do_test("join2", False)
+ def test_relationshiponsubclass_j1_data(self):
+ self._do_test("join1", True)
+ def test_relationshiponsubclass_j2_data(self):
+ self._do_test("join2", True)
+ def test_relationshiponsubclass_j3_nodata(self):
+ self._do_test("join3", False)
+ def test_relationshiponsubclass_j3_data(self):
+ self._do_test("join3", True)
+
+ def _do_test(self, jointype="join1", usedata=False):
class Person(AttrSettable):
pass
class Manager(Person):
)
def _generate_test(jointype="join1", usedata=False):
- def do_test(self):
+ def _do_test(self):
class Person(AttrSettable):
pass
class Manager(Person):
assert m.data.data == 'ms data'
do_test = function_named(
- do_test, 'test_relationship_on_base_class_%s_%s' % (
+ _do_test, 'test_relationship_on_base_class_%s_%s' % (
jointype, data and "nodata" or "data"))
return do_test
for t in reversed(metadata.sorted_tables):
t.delete().execute()
- def testjointo(self):
+ def test_join_to(self):
# class definitions
class PersistentObject(object):
def __init__(self, **kwargs):
primary_key=True ),
)
- def testbasic(self):
+ def test_basic(self):
class Principal(object):
def __init__(self, **kwargs):
for key, value in kwargs.items():
Column('foo_id', Integer, ForeignKey('foo.id')),
Column('bar_id', Integer, ForeignKey('bar.bid')))
- def testget(self):
+ def test_get(self):
class Foo(object):
def __init__(self, data=None):
self.data = data
# (ticket 185)
assert sess.query(Bar).get(b.id).id == b.id
- def testbasic(self):
+ def test_basic(self):
class Foo(object):
def __init__(self, data=None):
self.data = data
Column('blub_id', Integer, ForeignKey('blub.id')),
Column('foo_id', Integer, ForeignKey('foo.id')))
- def testbasic(self):
+ def test_basic(self):
class Foo(object):
def __init__(self, data=None):
self.data = data
found = [repr(l[0])] + sorted([repr(o) for o in l[0].foos])
eq_(found, compare)
- def testadvanced(self):
+ def test_advanced(self):
class Foo(object):
def __init__(self, data=None):
self.data = data
configure_mappers()
assert table1_mapper.primary_key == (table1.c.id,), table1_mapper.primary_key
- def testone(self):
+ def test_one(self):
self._testlist([Table1, Table2, Table1, Table2])
- def testtwo(self):
+ def test_two(self):
self._testlist([Table3])
- def testthree(self):
+ def test_three(self):
self._testlist([Table2, Table1, Table1B, Table3, Table3, Table1B, Table1B, Table2, Table1])
- def testfour(self):
+ def test_four(self):
self._testlist([
Table2('t2', [Data('data1'), Data('data2')]),
Table1('t1', []),
class RasterDocument(Document):
pass
- def testone(self):
+ def test_one(self):
product_mapper = mapper(Product, products_table,
polymorphic_on=products_table.c.product_type,
polymorphic_identity='product')
print(new)
assert orig == new == '<Assembly a1> specification=[<SpecLine 1.0 <Product p1>>, <SpecLine 1.0 <Detail d1>>] documents=None'
- def testtwo(self):
+ def test_two(self):
product_mapper = mapper(Product, products_table,
polymorphic_on=products_table.c.product_type,
polymorphic_identity='product')
print(new)
assert orig == new == '[<SpecLine 1.0 <Product p1>>, <SpecLine 1.0 <Detail d1>>]'
- def testthree(self):
+ def test_three(self):
product_mapper = mapper(Product, products_table,
polymorphic_on=products_table.c.product_type,
polymorphic_identity='product')
print(new)
assert orig == new == '<Assembly a1> specification=[<SpecLine 1.0 <Detail d1>>] documents=[<Document doc1>, <RasterDocument doc2>]'
- def testfour(self):
+ def test_four(self):
"""this tests the RasterDocument being attached to the Assembly, but *not* the Document. this means only
a "sub-class" task, i.e. corresponding to an inheriting mapper but not the base mapper, is created. """
a1 = session.query(Product).filter_by(name='a1').one()
assert len(session.query(Document).all()) == 0
- def testfive(self):
+ def test_five(self):
"""tests the late compilation of mappers"""
specification_mapper = mapper(SpecLine, specification_table,
session.add(b)
session.flush()
- def testDeleteRootTable(self):
+ def test_DeleteRootTable(self):
A = self.classes.A
session = create_session()
session.delete(a)
session.flush()
- def testDeleteMiddleTable(self):
+ def test_DeleteMiddleTable(self):
C = self.classes.C
session = create_session()
Column('t1c1', MySpecialType(30), ForeignKey('t1.col1')),
Column('t2c1', MySpecialType(30), ForeignKey('t2.col1')))
- def testm2m(self):
+ def test_m2m(self):
"""Many-to-many tables with special types for candidate keys."""
t2, t3, t1 = (self.tables.t2,
def teardown_class(cls):
metadata.drop_all()
- def testbasic(self):
+ def test_basic(self):
s = employees_table.select()
r = s.execute().fetchall()