Skip to content

Commit e527a5e

Browse files
authored
Merge pull request #2 from ines-bg/sabine
Sabine
2 parents 3807423 + 8f6c3c2 commit e527a5e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mypy/test/test_scope_behavior.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from mypy.nodes import FuncDef, SymbolTable, TypeInfo
2+
from mypy.scope import Scope
3+
4+
5+
def test_scope_module_and_function_behavior() -> None:
6+
scope = Scope()
7+
with scope.module_scope("mod1"):
8+
assert scope.current_module_id() == "mod1"
9+
# simulate function
10+
fake_func = FuncDef("f", None, None, None, None)
11+
with scope.function_scope(fake_func):
12+
assert "f" in scope.current_full_target()
13+
# simulate class inside function
14+
fake_class = TypeInfo(SymbolTable(), "C", None)
15+
with scope.class_scope(fake_class):
16+
assert "C" in scope.current_full_target()
17+
# leaving function restores module
18+
assert scope.current_full_target() == "mod1"

0 commit comments

Comments
 (0)