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