当前位置: 首页>>代码示例>>Python>>正文


Python ExampleDatabase.storage_for方法代码示例

本文整理汇总了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]
开发者ID:marekventur,项目名称:hypothesis,代码行数:9,代码来源:debug.py

示例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)) == []
开发者ID:subsetpark,项目名称:hypothesis,代码行数:9,代码来源:test_database.py

示例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()
开发者ID:pkqk,项目名称:hypothesis,代码行数:14,代码来源:strategytests.py

示例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()
开发者ID:subsetpark,项目名称:hypothesis,代码行数:17,代码来源:test_database.py

示例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)
开发者ID:subsetpark,项目名称:hypothesis,代码行数:7,代码来源:test_database.py

示例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))
开发者ID:subsetpark,项目名称:hypothesis,代码行数:6,代码来源:test_database.py

示例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()) == []
开发者ID:subsetpark,项目名称:hypothesis,代码行数:7,代码来源:test_database.py

示例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)
开发者ID:AlbertoPeon,项目名称:hypothesis,代码行数:7,代码来源:test_database.py


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