git reimport
This commit is contained in:
39
tests/zvk/event/test_reflection.py
Normal file
39
tests/zvk/event/test_reflection.py
Normal 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
|
Reference in New Issue
Block a user