コード例 #1
0
ファイル: test_database.py プロジェクト: trowt/hypothesis
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
0
ファイル: test_database.py プロジェクト: jwg4/hypothesis
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)) == []
コード例 #3
0
 def test_can_round_trip_through_the_database(self, template, rnd):
     empty_db = ExampleDatabase(backend=SQLiteBackend(u':memory:'), )
     try:
         storage = empty_db.storage(u'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()
コード例 #4
0
 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()
コード例 #5
0
ファイル: debug.py プロジェクト: thedrow/hypothesis
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()
コード例 #6
0
ファイル: test_database.py プロジェクト: GMadorell/hypothesis
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()
コード例 #7
0
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()
コード例 #8
0
ファイル: test_database.py プロジェクト: jwg4/hypothesis
def test_can_save_all_strings(s):
    db = ExampleDatabase()
    storage = db.storage(u'text')
    storage.save(tuple(s), text())
コード例 #9
0
ファイル: test_database.py プロジェクト: trowt/hypothesis
def test_can_save_all_strings(s):
    db = ExampleDatabase()
    storage = db.storage(u'text')
    storage.save(tuple(s), text())