Skip to content

Commit

Permalink
quick check: seems OK at first sight... Not 100% clear to me. Need mo…
Browse files Browse the repository at this point in the history
…re analysis.
  • Loading branch information
goto40 committed Aug 14, 2020
1 parent b110668 commit e4e09ec
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/functional/test_scoping/test_global_import_modules.py
Expand Up @@ -10,6 +10,17 @@
from pytest import raises


class Interface(object):
"""
user defined class to check if user defined classes
make problems if newly created objects are mixed
with exisiting objects from a previous model_from_xxx.
"""
def __init__(self, **kwargs):
for k in kwargs.keys():
setattr(self, k, kwargs[k])


def test_globalimports_basic_test_with_single_model_file():
"""
Basic test for the FQNGlobalRepo.
Expand Down Expand Up @@ -69,14 +80,19 @@ def test_globalimports_basic_test_with_single_model_file_and_global_repo():
# META MODEL DEF
#################################

# Interface is added as user defined class
# and used for two model_from_file
# calls.
my_meta_model = metamodel_from_file(
join(abspath(dirname(__file__)), 'interface_model2',
'Interface.tx'),
global_repository=True)
global_repository=True,
classes=[Interface])
my_meta_model.register_scope_providers(
{"*.*": scoping_providers.FQNGlobalRepo(
join(abspath(dirname(__file__)), 'interface_model2',
'model_a', '*.if'))})
# Note: FQN uses the name field (e.g. of an Interface)

#################################
# MODEL PARSING
Expand All @@ -98,6 +114,7 @@ def test_globalimports_basic_test_with_single_model_file_and_global_repo():

# check that "s.s1" is a reference to the socket interface
a = get_unique_named_object(my_model, "socket")
assert isinstance(a, Interface) # check that user defined class is used
s1 = get_unique_named_object(my_model, "s1")
assert a == s1.ref

Expand Down

0 comments on commit e4e09ec

Please sign in to comment.