本文整理汇总了Python中hypothesis.database.ExampleDatabase.storage方法的典型用法代码示例。如果您正苦于以下问题:Python ExampleDatabase.storage方法的具体用法?Python ExampleDatabase.storage怎么用?Python ExampleDatabase.storage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hypothesis.database.ExampleDatabase
的用法示例。
在下文中一共展示了ExampleDatabase.storage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_storage_does_not_error_if_the_database_is_invalid
# 需要导入模块: from hypothesis.database import ExampleDatabase [as 别名]
# 或者: from hypothesis.database.ExampleDatabase import storage [as 别名]
def test_storage_does_not_error_if_the_database_is_invalid():
database = ExampleDatabase()
strat = integers()
key = u'wtf'
ints = database.storage(key)
database.backend.save(key, u'["hi", "there"]')
assert list(ints.fetch(strat)) == []
示例2: test_can_round_trip_through_the_database
# 需要导入模块: from hypothesis.database import ExampleDatabase [as 别名]
# 或者: from hypothesis.database.ExampleDatabase import storage [as 别名]
def test_can_round_trip_through_the_database(self, template, rnd):
empty_db = ExampleDatabase(backend=SQLiteBackend(":memory:"))
try:
storage = empty_db.storage("round trip")
storage.save(template, strat)
values = list(storage.fetch(strat))
assert len(values) == 1
assert strat.to_basic(template) == strat.to_basic(values[0])
finally:
empty_db.close()
示例3: via_database
# 需要导入模块: from hypothesis.database import ExampleDatabase [as 别名]
# 或者: from hypothesis.database.ExampleDatabase import storage [as 别名]
def via_database(spec, strat, template):
db = ExampleDatabase()
key = u'via_database'
try:
s = db.storage(key)
s.save(template, strat)
results = list(s.fetch(strat))
assert len(results) == 1
return results[0]
finally:
db.close()
示例4: run_round_trip
# 需要导入模块: from hypothesis.database import ExampleDatabase [as 别名]
# 或者: from hypothesis.database.ExampleDatabase import storage [as 别名]
def run_round_trip(specifier, value, format=None, backend=None):
if backend is not None:
backend = backend()
else:
backend = SQLiteBackend()
db = ExampleDatabase(format=format, backend=backend)
try:
storage = db.storage(u'round trip')
storage.save(value, specifier)
saved = list(storage.fetch(specifier))
assert len(saved) == 1
assert specifier.to_basic(saved[0]) == specifier.to_basic(value)
finally:
db.close()
示例5: test_can_save_all_strings
# 需要导入模块: from hypothesis.database import ExampleDatabase [as 别名]
# 或者: from hypothesis.database.ExampleDatabase import storage [as 别名]
def test_can_save_all_strings(s):
db = ExampleDatabase()
storage = db.storage(u'text')
storage.save(tuple(s), text())