git reimport

This commit is contained in:
2019-03-15 15:02:19 +04:00
commit 742797309a
90 changed files with 4411 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import pytest
from zvk.event.reflection import run_with_env
def test_reflection():
calls = 0
def no_args():
nonlocal calls
calls += 1
run_with_env(None, no_args)
assert calls == 1
def some_args(a, b=1):
nonlocal calls
calls += 1
assert a == 1
assert b == 2
run_with_env(dict(a=1, b=2), some_args)
assert calls == 2
def default_check(a, b=1):
nonlocal calls
calls += 1
assert a == 1
assert b == 1
run_with_env(dict(a=1), default_check)
assert calls == 3
with pytest.raises(TypeError):
run_with_env(None, default_check)
assert calls == 3