def write(field, i): """Write the given value to the pickled db.""" PickledDB.instance = None orion_db = PickledDB(host='orion_db.pkl') try: orion_db.write('concurrent', {field: i}) except DuplicateKeyError: print('dup') pass print(field, i)
def test_instantiation_and_singleton(self): """Test create just one object, that object persists between calls.""" database = Database(of_type="PickledDB", name="orion_test") assert isinstance(database, PickledDB) assert database is PickledDB() assert database is Database() with pytest.raises(SingletonAlreadyInstantiatedError): Database("fire", [], {"it_matters": "it's singleton"})
def orion_db(): """Return PickledDB wrapper instance initiated with test opts.""" PickledDB.instance = None orion_db = PickledDB(host='orion_db.pkl') yield orion_db