• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dbtest.setupClass函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sqlobject.tests.dbtest.setupClass函数的典型用法代码示例。如果您正苦于以下问题:Python setupClass函数的具体用法?Python setupClass怎么用?Python setupClass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setupClass函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_mxDateTime

    def test_mxDateTime():
        setupClass(DateTime2)
        _now = now()
        dt2 = DateTime2(col1=_now, col2=_now,
                        col3=Time(_now.hour, _now.minute, _now.second))

        assert isinstance(dt2.col1, col.DateTimeType)
        assert dt2.col1.year == _now.year
        assert dt2.col1.month == _now.month
        assert dt2.col1.day == _now.day
        assert dt2.col1.hour == _now.hour
        assert dt2.col1.minute == _now.minute
        assert dt2.col1.second == int(_now.second)

        assert isinstance(dt2.col2, col.DateTimeType)
        assert dt2.col2.year == _now.year
        assert dt2.col2.month == _now.month
        assert dt2.col2.day == _now.day
        if getConnection().dbName == "sqlite":
            assert dt2.col2.hour == _now.hour
            assert dt2.col2.minute == _now.minute
            assert dt2.col2.second == int(_now.second)
        else:
            assert dt2.col2.hour == 0
            assert dt2.col2.minute == 0
            assert dt2.col2.second == 0

        assert isinstance(dt2.col3, (col.DateTimeType, col.TimeType))
        assert dt2.col3.hour == _now.hour
        assert dt2.col3.minute == _now.minute
        assert dt2.col3.second == int(_now.second)
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:31,代码来源:test_datetime.py


示例2: test_foreignKey

def test_foreignKey():
    setupClass([SOTestSO4, SOTestSO3])
    test3_order = [col.name for col in SOTestSO3.sqlmeta.columnList]
    assert test3_order == ['name', 'otherID', 'other2ID']
    tc3 = SOTestSO3(name='a')
    assert tc3.other is None
    assert tc3.other2 is None
    assert tc3.otherID is None
    assert tc3.other2ID is None
    tc4a = SOTestSO4(me='1')
    tc3.other = tc4a
    assert tc3.other == tc4a
    assert tc3.otherID == tc4a.id
    tc4b = SOTestSO4(me='2')
    tc3.other = tc4b.id
    assert tc3.other == tc4b
    assert tc3.otherID == tc4b.id
    tc4c = SOTestSO4(me='3')
    tc3.other2 = tc4c
    assert tc3.other2 == tc4c
    assert tc3.other2ID == tc4c.id
    tc4d = SOTestSO4(me='4')
    tc3.other2 = tc4d.id
    assert tc3.other2 == tc4d
    assert tc3.other2ID == tc4d.id
    tcc = SOTestSO3(name='b', other=tc4a)
    assert tcc.other == tc4a
    tcc2 = SOTestSO3(name='c', other=tc4a.id)
    assert tcc2.other == tc4a
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:29,代码来源:test_basic.py


示例3: test_sqlite_factory_str

def test_sqlite_factory_str():
    setupClass(SQLiteFactoryTest)

    if SQLiteFactoryTest._connection.dbName != "sqlite":
        pytest.skip("These tests require SQLite")
    if not SQLiteFactoryTest._connection.using_sqlite2:
        pytest.skip("These tests require SQLite v2+")

    factory = [None]

    def SQLiteConnectionFactory(sqlite):
        class MyConnection(sqlite.Connection):
            pass
        factory[0] = MyConnection
        return MyConnection

    from sqlobject.sqlite import sqliteconnection
    sqliteconnection.SQLiteConnectionFactory = SQLiteConnectionFactory

    setSQLiteConnectionFactory(SQLiteFactoryTest, "SQLiteConnectionFactory")

    conn = SQLiteFactoryTest._connection.makeConnection()
    assert factory[0]
    assert isinstance(conn, factory[0])
    del sqliteconnection.SQLiteConnectionFactory
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:25,代码来源:test_sqlite.py


示例4: test_creation_fail2

def test_creation_fail2():
    """
    Try to create two Managers with the same position.
    This should fail without leaving any partial records in
    the database.

    """
    setupClass([DIManager, DIEmployee, DIPerson])

    kwargs = {'firstName': 'John', 'lastName': 'Doe',
              'position': 'Project Manager'}
    DIManager(**kwargs)
    persons = DIEmployee.select(DIPerson.q.firstName == 'John')
    assert persons.count() == 1

    kwargs = {'firstName': 'John', 'lastName': 'Doe II',
              'position': 'Project Manager'}
    raises(Exception, DIManager, **kwargs)
    persons = DIPerson.select(DIPerson.q.firstName == 'John')
    assert persons.count() == 1

    if not supports('transactions'):
        skip("Transactions aren't supported")
    transaction = DIPerson._connection.transaction()
    kwargs = {'firstName': 'John', 'lastName': 'Doe III',
              'position': 'Project Manager'}
    raises(Exception, DIManager, connection=transaction, **kwargs)
    transaction.rollback()
    transaction.begin()
    persons = DIPerson.select(DIPerson.q.firstName == 'John',
                              connection=transaction)
    assert persons.count() == 1
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:32,代码来源:test_deep_inheritance.py


示例5: setup

def setup():
    setupClass(InheritablePerson)
    setupClass(Employee)

    Employee(firstName='Project', lastName='Leader',
             so_position='Project leader')
    InheritablePerson(firstName='Oneof', lastName='Authors')
开发者ID:sqlobject,项目名称:sqlobject,代码行数:7,代码来源:test_inheritance.py


示例6: test_mxDateTime

    def test_mxDateTime():
        setupClass(DateTime2)
        _now = now()
        dt2 = DateTime2(col1=_now, col2=_now.pydate(),
                        col3=Time(_now.hour, _now.minute, _now.second))

        assert isinstance(dt2.col1, col.DateTimeType)
        assert dt2.col1.year == _now.year
        assert dt2.col1.month == _now.month
        assert dt2.col1.day == _now.day
        assert dt2.col1.hour == _now.hour
        assert dt2.col1.minute == _now.minute
        assert dt2.col1.second == int(_now.second)

        assert isinstance(dt2.col2, col.DateTimeType)
        assert dt2.col2.year == _now.year
        assert dt2.col2.month == _now.month
        assert dt2.col2.day == _now.day
        assert dt2.col2.hour == 0
        assert dt2.col2.minute == 0
        assert dt2.col2.second == 0

        assert isinstance(dt2.col3, (col.DateTimeType, col.TimeType))
        assert dt2.col3.hour == _now.hour
        assert dt2.col3.minute == _now.minute
        assert dt2.col3.second == int(_now.second)
开发者ID:sqlobject,项目名称:sqlobject,代码行数:26,代码来源:test_datetime.py


示例7: setup_method

 def setup_method(self, meth):
     setupClass([PersonJNew2, AddressJNew2])
     p1 = PersonJNew2(name='bob')
     p2 = PersonJNew2(name='sally')
     for z in ['11111', '22222', '33333']:
         AddressJNew2(zip=z, personJNew2=p1)
     AddressJNew2(zip='00000', personJNew2=p2)
开发者ID:sqlobject,项目名称:sqlobject,代码行数:7,代码来源:test_new_joins.py


示例8: testDestroySelf

def testDestroySelf():
    setupClass(NoCache)
    old = NoCache._connection.cache
    NoCache._connection.cache = cache.CacheSet(cache=False)
    value = NoCache(name='test')
    value.destroySelf()
    NoCache._connection.cache = old
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:7,代码来源:test_delete.py


示例9: setup_method

 def setup_method(self, meth):
     setupClass([PersonJoinerNew3, AddressJoinerNew3])
     p1 = PersonJoinerNew3(name='bob')
     p2 = PersonJoinerNew3(name='sally')
     for z in ['11111', '22222', '33333']:
         AddressJoinerNew3(zip=z, personJoinerNew3=p1)
     AddressJoinerNew3(zip='00000', personJoinerNew3=p2)
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:7,代码来源:test_new_joins.py


示例10: test_style

def test_style():
    setupClass([SOStyleTest2, SOStyleTest1])
    st1 = SOStyleTest1(a='something', st2=None)
    st2 = SOStyleTest2(b='whatever')
    st1.st2 = st2
    assert st1.sqlmeta.columns['st2ID'].dbName == 'idst2'
    assert st1.st2 == st2
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:7,代码来源:test_style.py


示例11: test_sub

def test_sub():
    setupClass(Super)
    setupClass(Sub)
    s1 = Sub(name='one', name2='1')
    Sub(name='two', name2='2')  # s2
    s3 = Sub.get(s1.id)
    assert s1 == s3
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:7,代码来源:test_inheritance.py


示例12: test_super

def test_super():
    setupClass(Super)
    setupClass(Sub)
    s1 = Super(name='one')
    Super(name='two')  # s2
    s3 = Super.get(s1.id)
    assert s1 == s3
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:7,代码来源:test_inheritance.py


示例13: test_sqlite_aggregate

def test_sqlite_aggregate():
    setupClass(SQLiteFactoryTest)

    if not SQLiteFactoryTest._connection.using_sqlite2:
        pytest.skip("These tests require SQLite v2+")

    def SQLiteConnectionFactory(sqlite):
        class MyConnection(sqlite.Connection):
            def __init__(self, *args, **kwargs):
                super(MyConnection, self).__init__(*args, **kwargs)
                self.create_aggregate("group_concat", 1, self.group_concat)

            class group_concat:
                def __init__(self):
                    self.acc = []

                def step(self, value):
                    if isinstance(value, string_type):
                        self.acc.append(value)
                    else:
                        self.acc.append(str(value))

                def finalize(self):
                    self.acc.sort()
                    return ", ".join(self.acc)

        return MyConnection

    setSQLiteConnectionFactory(SQLiteFactoryTest, SQLiteConnectionFactory)

    SQLiteFactoryTest(name='sqlobject')
    SQLiteFactoryTest(name='sqlbuilder')
    assert SQLiteFactoryTest.select(orderBy="name").\
        accumulateOne("group_concat", "name") == \
        "sqlbuilder, sqlobject"
开发者ID:sqlobject,项目名称:sqlobject,代码行数:35,代码来源:test_sqlite.py


示例14: testUnicode

def testUnicode():
    setupClass(EnumUnicode)

    EnumUnicode(n=u'a', l='a')
    EnumUnicode(n=u'b', l=u'b')
    EnumUnicode(n=u'\u201c', l='a')
    EnumUnicode(n=u'\u201c', l=u'b')
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:7,代码来源:test_enum.py


示例15: testDeleteRelatedJoins

def testDeleteRelatedJoins():
    setupClass([Service, ServiceGroup])
    service = Service()
    service_group = ServiceGroup()
    service.addServiceGroup(service_group)
    service.destroySelf()
    service_group = ServiceGroup.get(service_group.id)
    assert len(service_group.services) == 0
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:8,代码来源:test_delete.py


示例16: test_sqlmeta_inherited_idName

def test_sqlmeta_inherited_idName():
    setupClass([SOTestSqlmeta1, SOTestSqlmeta2])
    assert SOTestSqlmeta1.sqlmeta.idName == "my_id"
    assert SOTestSqlmeta2.sqlmeta.idName == "SOTestSqlmeta2ID"
    assert SOTestSqlmeta3.sqlmeta.idName == "my_id"
    assert SOTestSqlmeta4.sqlmeta.idName == "SOTestSqlmeta4ID"
    assert SOTestSqlmeta5.sqlmeta.idName == "my_id"
    assert SOTestSqlmeta6.sqlmeta.idName == "SOTestSqlmeta6ID"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:8,代码来源:test_sqlmeta_idName.py


示例17: setupComplexNames

def setupComplexNames():
    setupClass(ComplexNames)
    inserts(ComplexNames, [('aj', 'baker', '555-444-333', 34),
                           ('joe', 'robbins', '444-555-333', 34),
                           ('tim', 'jackson', '555-444-222', 32),
                           ('joe', 'baker', '222-111-000', 24),
                           ('zoe', 'robbins', '444-555-333', 46)],
            schema='firstName lastName phone age')
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:8,代码来源:test_complex_sorting.py


示例18: test_2perform_join

def test_2perform_join():
    setupClass(JoinAlias)
    JoinAlias(name="grandparent", parent=None)
    JoinAlias(name="parent", parent="grandparent")
    JoinAlias(name="child", parent="parent")
    alias = Alias(JoinAlias)
    select = JoinAlias.select(JoinAlias.q.parent == alias.q.name)
    assert select.count() == 2
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:8,代码来源:test_aliases.py


示例19: test_1syntax

def test_1syntax():
    setupClass(JoinAlias)
    alias = Alias(JoinAlias)
    select = JoinAlias.select(JoinAlias.q.parent == alias.q.name)
    assert str(select) == \
        "SELECT join_alias.id, join_alias.name, join_alias.parent " \
        "FROM join_alias, join_alias  join_alias_alias1 " \
        "WHERE ((join_alias.parent) = (join_alias_alias1.name))"
开发者ID:LutzSteinborn,项目名称:sqlobject,代码行数:8,代码来源:test_aliases.py


示例20: setup_method

 def setup_method(self, meth):
     setupClass(Person)
     setupClass(Phone)
     for n in ['jane', 'tim', 'bob', 'jake']:
         Person(name=n)
     for p in ['555-555-5555', '555-394-2930',
               '444-382-4854']:
         Phone(phone=p)
开发者ID:sqlobject,项目名称:sqlobject,代码行数:8,代码来源:test_auto.py



注:本文中的sqlobject.tests.dbtest.setupClass函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sqlparse.format函数代码示例发布时间:2022-05-27
下一篇:
Python sqlbuilder.sqlrepr函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap