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

Python test.raises函数代码示例

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

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



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

示例1: test_immutable_entity_view_field_value

 def test_immutable_entity_view_field_value(self):
     foo1 = ex(db.Foo.t.create(name='foo1'))
     foo2 = ex(db.Foo.t.create(name='foo2'))
     bar = ex(db.Bar.t.create(foo_list=[foo1]))
     assert raises(AttributeError, getattr, bar.foo_list, 'append')
     v = bar.v.default()
     assert raises(AttributeError, getattr, v.foo_list, 'append')
开发者ID:Schevo,项目名称:schevo,代码行数:7,代码来源:test_field_entitylist.py


示例2: test_find_extremes

 def test_find_extremes(self):
     bt = BTree()
     assert raises(AssertionError, bt.get_min_item)
     assert raises(AssertionError, bt.get_max_item)
     map(bt.add, range(100))
     assert bt.get_min_item() == (0, True)
     assert bt.get_max_item() == (99, True)
开发者ID:Schevo,项目名称:schevo,代码行数:7,代码来源:test_store_btree.py


示例3: test_only_one_top_level

 def test_only_one_top_level(self):
     # Cannot pass more than one top-level transaction.
     tx1 = db.User.t.create(name='1')
     tx2 = db.User.t.create(name='2')
     assert raises(RuntimeError, db.execute, tx1, tx2)
     # Must pass at least one top-level transaction.
     assert raises(RuntimeError, db.execute)
开发者ID:Schevo,项目名称:schevo,代码行数:7,代码来源:test_transaction.py


示例4: test_extra_fields

 def test_extra_fields(self):
     # A normal Gender create does not normally have fget fields in
     # the transaction, but in ProblemGender we've inserted them as
     # fields of different types.
     tx = db.ProblemGender.t.create()
     assert sorted(tx.s.field_map().keys()) == [
         'code', 'count', 'foo', 'name']
     # When executing the transaction, the superclass T.Create
     # should ignore .count since it was an fget field.
     tx.code = 'X'
     tx.name = 'xyz'
     tx.count = 'foo'
     tx.foo = 5
     pgender = db.execute(tx)
     # Accessing the count directly should result in a calculated
     # value.
     assert pgender.count == 0
     # Peek in the database to make sure that it didn't get stored
     # in the database as a string though, since in cases where the
     # type of the calculated field is an entity field
     assert db._entity_field(
         'ProblemGender', pgender.s.oid, 'count') != 'foo'
     assert raises(KeyError, db._entity_field, 'ProblemGender',
                   pgender.s.oid, 'foo')
     # Same thing for updates.
     tx = pgender.t.update()
     tx.count = 'bar'
     tx.foo = 10
     pgender = db.execute(tx)
     assert pgender.count == 0
     assert db._entity_field(
         'ProblemGender', pgender.s.oid, 'count') != 'foo'
     assert raises(KeyError, db._entity_field, 'ProblemGender',
                   pgender.s.oid, 'foo')
开发者ID:Schevo,项目名称:schevo,代码行数:34,代码来源:test_transaction.py


示例5: test_transfer_account_suspended

 def test_transfer_account_suspended(self):
     betty = db.Person.findone(name='Betty Rubble')
     family = db.Account.findone(owner=betty, name='Family')
     savings = db.Account.findone(owner=betty, name='Savings')
     # Attempt transfer from family to savings.
     tx = family.t.transfer()
     tx.to_account = savings
     tx.amount = 0.01
     assert raises(Exception, db.execute, tx)
     # Attempt transfer from savings to family.
     tx = savings.t.transfer()
     tx.to_account = family
     tx.amount = 0.01
     assert raises(Exception, db.execute, tx)
开发者ID:Schevo,项目名称:schevo,代码行数:14,代码来源:test_bank.py


示例6: test_remove_entity_field_then_readd

 def test_remove_entity_field_then_readd(self):
     schema1 = fix("""
     class Foo(E.Entity):
         bar = f.entity('Bar')
         baz = f.integer()
     class Bar(E.Entity):
         bof = f.string()
     """)
     schema2 = fix("""
     class Foo(E.Entity):
         baz = f.integer()
     class Bar(E.Entity):
         bof = f.string()
     """)
     schema3 = fix("""
     class Foo(E.Entity):
         bar = f.entity('Bar')
         baz = f.integer()
     class Bar(E.Entity):
         bof = f.string()
     """)
     self.sync(schema1)
     bar = db.execute(db.Bar.t.create(bof='fob'))
     foo = db.execute(db.Foo.t.create(bar=bar, baz=12))
     foo_oid = foo.s.oid
     bar_oid = bar.s.oid
     assert bar.s.count() == 1
     # Evolve.
     self.evolve(schema2, version=2)
     foo = db.Foo[foo_oid]
     bar = db.Bar[bar_oid]
     assert foo.baz == 12
     raises(AttributeError, getattr, foo, 'bar')
     assert bar.s.count() == 0
     # Attempt to update the entity.
     tx = foo.t.update()
     tx.baz = 5
     db.execute(tx)
     assert foo.baz == 5
     # Evolve.
     self.evolve(schema3, version=3)
     foo = db.Foo[foo_oid]
     bar = db.Bar[bar_oid]
     assert foo.bar is UNASSIGNED
     assert foo.baz == 5
     tx = foo.t.update()
     tx.bar = bar
     db.execute(tx)
     assert foo.bar == bar
     assert bar.s.count() == 1
开发者ID:gldnspud,项目名称:schevo,代码行数:50,代码来源:test_evolve.py


示例7: test_database_decoration

 def test_database_decoration(self):
     # This label is assigned automatically.
     assert label.label(db) == u'Schevo Database'
     # It can be easily overridden.
     label.relabel(db, 'Custom Label')
     assert label.label(db) == u'Custom Label'
     # When reopening the database, the label persists.
     self.reopen()
     assert label.label(db) == u'Custom Label'
     # Cannot change the label during a transaction.
     def fn(db):
         label.relabel(db, u'Custom Label 2')
     tx = transaction.CallableWrapper(fn)
     raises(error.DatabaseExecutingTransaction,
            db.execute, tx)
开发者ID:Schevo,项目名称:schevo,代码行数:15,代码来源:test_label.py


示例8: test_pop

 def test_pop(self):
     assert raises(KeyError, set_type().pop)
     s1 = set_type('asdf')
     x = s1.pop()
     assert x not in s1
     assert len(s1) == 3
     assert (s1 | set_type(x)) == set_type('asdf')
开发者ID:Schevo,项目名称:schevo,代码行数:7,代码来源:test_store_persistent_set.py


示例9: test_remove

 def test_remove(self):
     s1 = set_type()
     assert raises(KeyError, s1.remove, 1)
     assert s1 == set_type()
     s1 = set_type('asdf')
     s1.remove('a')
     assert s1 == set_type('sdf')
开发者ID:Schevo,项目名称:schevo,代码行数:7,代码来源:test_store_persistent_set.py


示例10: test_delete_cannot_skip_revisions

 def test_delete_cannot_skip_revisions(self):
     tx = db.User.t.create(name='foo')
     user = db.execute(tx)
     tx1 = user.t.update(name='bar')
     tx2 = user.t.delete()
     db.execute(tx1)
     assert raises(error.TransactionExpired, db.execute, tx2)
开发者ID:Schevo,项目名称:schevo,代码行数:7,代码来源:test_transaction.py


示例11: test_a

 def test_a(self):
     filename = tempfile.mktemp()
     s = FileStorage2(filename)
     connection = Connection(s)
     root = connection.get_root()
     root['a'] = Persistent()
     root['a'].b = 1
     connection.commit()
     root['a'].b = 2
     connection.commit()
     s.close()
     hc = HistoryConnection(filename)
     a = hc.get_root()['a']
     assert len(hc.get_storage().index.history) == 4
     assert a.b == 2
     hc.previous()
     assert a.b == 1
     hc.next()
     assert a.b == 2
     hc.previous()
     assert a.b == 1
     hc.previous()
     assert a._p_is_ghost()
     assert not hasattr(a, '__dict__')
     assert isinstance(a, Persistent)
     assert raises(KeyError, getattr, a, 'b')
     assert hc.get(a._p_oid) is a
     hc.next()
     assert a.b == 1
     hc.get_storage().fp.close()
     os.unlink(filename)
开发者ID:Schevo,项目名称:schevo,代码行数:31,代码来源:test_store_history.py


示例12: test_remove_extent_restricted

 def test_remove_extent_restricted(self):
     schema1 = fix("""
     class Foo(E.Entity):
         bar = f.entity(allow='Bar')
     class Bar(E.Entity):
         baz = f.integer()
     """)
     schema2 = fix("""
     class Foo(E.Entity):
         bar = f.entity(allow='Bar')
     class Bof(E.Entity):
         baz = f.integer()
     """)
     self.sync(schema1)
     raises(error.ExtentDoesNotExist, self.sync, schema2)
     assert db.schema_source == schema1
     assert db.extent_names() == ['Bar', 'Foo']
开发者ID:gldnspud,项目名称:schevo,代码行数:17,代码来源:test_evolve.py


示例13: test_transfer_insufficient_funds

 def test_transfer_insufficient_funds(self):
     fred = db.Person.findone(name='Fred Flintstone')
     business = db.Account.findone(owner=fred, name='Business')
     personal = db.Account.findone(owner=fred, name='Personal')
     # Attempt transfer from personal to business.
     tx = personal.t.transfer()
     tx.to_account = business
     tx.amount = 205.00
     assert raises(Exception, db.execute, tx)
开发者ID:Schevo,项目名称:schevo,代码行数:9,代码来源:test_bank.py


示例14: test_field_requirements

 def test_field_requirements(self):
     tx = db.User.t.create()
     # User was not specified, so transaction shouldn't succeed.
     assert raises(AttributeError, db.execute, tx)
     # Even if the transaction's fields are modified, the entity's
     # field spec should remain enforced.
     tx.f.name.required = False
     assert raises(AttributeError, db.execute, tx)
     # Age should not be required though.
     tx = db.User.t.create()
     tx.name = 'foo'
     result = db.execute(tx)
     assert result.age is UNASSIGNED
     # When updating, restrictions should still be enforced.
     tx = result.t.update(name=UNASSIGNED)
     assert raises(AttributeError, db.execute, tx)
     tx.f.name.required = False
     assert raises(AttributeError, db.execute, tx)
开发者ID:Schevo,项目名称:schevo,代码行数:18,代码来源:test_entity_extent.py


示例15: test_unassign_when_unassigned_disallowed

 def test_unassign_when_unassigned_disallowed(self):
     bar1, bar2, bar3, bar4, bar5 = db.Bar.by('name')
     fee = ex(db.Fee.t.create(
         name='fee',
         bar_list=[bar1, bar2, bar3, bar4, bar5, bar4, bar3],
         ))
     assert list(fee.bar_list) == [bar1, bar2, bar3, bar4, bar5, bar4, bar3]
     call = ex, bar4.t.delete()
     assert raises(ValueError, *call)
开发者ID:gldnspud,项目名称:schevo,代码行数:9,代码来源:test_on_delete.py


示例16: test_disallow_duplicates

 def test_disallow_duplicates(self):
     # Make sure that duplicates are allowed by default.
     foo = ex(db.Foo.t.create(name='foo'))
     bar = ex(db.Bar.t.create(foo_list=[foo, foo]))
     assert list(bar.foo_list) == [foo, foo]
     # Make sure they are disallowed when allow_duplicates is False.
     tx = db.Bee.t.create(foo_list=[foo, foo])
     call = ex, tx
     assert raises(ValueError, *call)
开发者ID:Schevo,项目名称:schevo,代码行数:9,代码来源:test_field_entitylist.py


示例17: test_check_memory_storage

 def test_check_memory_storage(self):
     b = MemoryStorage()
     assert b.new_oid() == p64(1)
     assert b.new_oid() == p64(2)
     assert raises(KeyError, b.load, p64(0))
     record = pack_record(p64(0), 'ok', '')
     b.begin()
     b.store(p64(0), record)
     b.end()
     b.sync()
     b.begin()
     b.store(p64(1), pack_record(p64(1), 'no', ''))
     b.end()
     assert len(list(b.gen_oid_record())) == 2
     assert record == b.load(p64(0))
     records = b.bulk_load([p64(0), p64(1)])
     assert len(list(records)) == 2
     records = b.bulk_load([p64(0), p64(1), p64(2)])
     assert raises(KeyError, list, records)
开发者ID:Schevo,项目名称:schevo,代码行数:19,代码来源:test_store_storage.py


示例18: test_allow_unassigned

 def test_allow_unassigned(self):
     # Make sure that UNASSIGNED members are disallowed by default.
     foo = ex(db.Foo.t.create(name='foo'))
     tx = db.Bar.t.create(foo_list=[foo, UNASSIGNED])
     call = ex, tx
     assert raises(ValueError, *call)
     # Make sure they are allowed when allow_unassigned is True.
     tx = db.Boo.t.create(foo_list=[foo, UNASSIGNED])
     boo = db.execute(tx)
     assert list(boo.foo_list) == [foo, UNASSIGNED]
开发者ID:Schevo,项目名称:schevo,代码行数:10,代码来源:test_field_entitylist.py


示例19: test_remove_min_one

 def test_remove_min_one(self):
     bar1 = db.Bar.findone(name=u'bar 1')
     bar2 = db.Bar.findone(name=u'bar 2')
     foo1 = db.Foo.findone(name=u'foo 1')
     db.execute(bar1.t.delete())
     assert list(foo1.bars) == [bar2]
     # Deleting bar2 should fail due to foo1.bars becoming an empty
     # list, which is not allowed.
     call = db.execute, bar2.t.delete()
     assert raises(ValueError, *call)
开发者ID:gldnspud,项目名称:schevo,代码行数:10,代码来源:test_on_delete.py


示例20: test_min_size_max_size

 def test_min_size_max_size(self):
     # Make sure that empty lists are allowed by default.
     foo = ex(db.Foo.t.create(name='foo'))
     tx = db.Bar.t.create(foo_list=[])
     bar = db.execute(tx)
     assert list(bar.foo_list) == []
     # Make sure they are not allowed when min_size > 0.
     tx = db.Baz.t.create(foo_list=[])
     call = ex, tx
     assert raises(ValueError, *call)
开发者ID:Schevo,项目名称:schevo,代码行数:10,代码来源:test_field_entitylist.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python common._函数代码示例发布时间:2022-05-27
下一篇:
Python scheme_tokens.tokenize_lines函数代码示例发布时间: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