def test_set_overwrite():
    context = Context()
    context.set('a', 1)
    with pytest.raises(Exception) as e:
        context.set('a', 2)
    assert str(e.value) == "Context variable 'a' has been already set."
    assert context.get('a') == 1
Exemple #2
0
from spinta.commands import load, wait, prepare, check
from spinta.components import Context, Store
from spinta.utils.commands import load_commands
from spinta import components
from spinta.config import Config

logging.basicConfig(
    level=logging.INFO,
    format='%(levelname)s: %(message)s',
)

c = Config()
c.read()

load_commands(c.get('commands', 'modules', cast=list))

context = Context()
config = context.set('config', components.Config())
store = context.set('store', Store())

load(context, config, c)
load(context, store, c)
check(context, store)

wait(context, store, c)

prepare(context, store.internal)
prepare(context, store)

set_context(context)